Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cc7ac71

Browse files
Code refactor/cleanup; cleanup typings
1 parent 9abafce commit cc7ac71

File tree

20 files changed

+134
-117
lines changed

20 files changed

+134
-117
lines changed

‎GhostUI/ClientApp/package-lock.json

Lines changed: 21 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎GhostUI/ClientApp/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"core-js": "^3.6.5",
2424
"register-service-worker": "^1.7.1",
2525
"vue": "^2.6.12",
26-
"vue-class-component": "^7.2.5",
26+
"vue-class-component": "^7.2.6",
2727
"vue-property-decorator": "^9.0.0",
2828
"vue-router": "^3.4.3",
2929
"vue-snotify": "^3.2.1",
@@ -32,7 +32,7 @@
3232
},
3333
"devDependencies": {
3434
"@testing-library/jest-dom": "^5.11.4",
35-
"@types/jest": "^26.0.13",
35+
"@types/jest": "^26.0.14",
3636
"@vue/cli-plugin-babel": "^4.5.6",
3737
"@vue/cli-plugin-e2e-nightwatch": "^4.5.6",
3838
"@vue/cli-plugin-pwa": "^4.5.6",
@@ -42,10 +42,10 @@
4242
"@vue/test-utils": "1.1.0",
4343
"node-sass": "^4.14.1",
4444
"sass-loader": "^10.0.2",
45-
"ts-jest": "^26.3.0",
46-
"typescript": "^4.0.2",
45+
"ts-jest": "^26.4.0",
46+
"typescript": "^4.0.3",
4747
"vue-svg-loader": "^0.16.0",
4848
"vue-template-compiler": "^2.6.12",
49-
"vuex-module-decorators": "^0.17.0"
49+
"vuex-module-decorators": "^1.0.1"
5050
}
5151
}

‎GhostUI/ClientApp/src/api/signalR.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ class SignalRService {
3131
}
3232

3333
public startConnection(): void {
34-
if (this._hubConnection.state !== HubConnectionState.Connected) {
34+
if (this._hubConnection.state === HubConnectionState.Disconnected) {
3535
setTimeout(() => {
36-
this._hubConnection.start()
37-
.catch(err => console.error(err));
36+
this._hubConnection.start().catch((e) => console.error(e));
3837
}, _signalrConfig.CONNECTION_DELAY);
3938
}
4039
}

‎GhostUI/ClientApp/src/assets/style/scss/scoped/settings.scss

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@
3333
width: 11rem;
3434
min-width: 11rem;
3535
display: block;
36-
padding-top: 10px;
37-
padding-bottom: 5px;
36+
padding: 5px 0;
3837
background-color: white;
3938
position: absolute;
4039
z-index: 1000;
4140
user-select: none;
42-
border-radius: 3px;
41+
border-radius: 0.25rem;
4342
box-shadow: 0 2px 7px 0 rgba(0,0,0,.08), 0 5px 20px 0 rgba(0,0,0,.06);
4443

4544
&:before,
@@ -69,11 +68,12 @@
6968
.header-title {
7069
line-height: 35px;
7170
font-size: 18px;
71+
font-weight: 600;
7272
text-align: center;
7373
color: #7f888f;
7474
text-transform: uppercase;
75+
padding-bottom: 3px;
7576
margin-bottom: 0.5rem;
76-
width: 73%;
7777
margin-left: auto;
7878
margin-right: auto;
7979
border-bottom: 1px solid rgba(0,0,0,.125);
@@ -94,5 +94,13 @@
9494
margin-right: 0.3rem;
9595
}
9696
}
97+
98+
> li:not(:first-of-type) {
99+
transition: background-color .2s ease-out;
100+
101+
:hover {
102+
background-color: #f5f5f5;
103+
}
104+
}
97105
}
98106
}

‎GhostUI/ClientApp/src/components/Authenticator.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,25 @@
1414

1515
<script lang="ts">
1616
import { Component, Prop, Watch, Vue } from "vue-property-decorator";
17-
import { AuthStatus, AuthStatusEnum } from "@/store/modules/auth";
17+
import { AuthStatusEnum } from "@/store/modules/auth";
1818
1919
@Component
2020
export default class Authenticator extends Vue {
21-
@Prop() public readonly authStatus: AuthStatus;
21+
@Prop() public readonly authStatus: AuthStatusEnum;
2222
@Prop({ default: 1500 }) public readonly delay: number;
2323
24+
private readonly authStatusEmitOnValues: AuthStatusEnum[] = [
25+
AuthStatusEnum.FAIL,
26+
AuthStatusEnum.SUCCESS,
27+
];
28+
2429
get isLoading(): boolean {
2530
return this.authStatus !== AuthStatusEnum.NONE;
2631
}
2732
2833
@Watch('authStatus')
29-
public onStatusChange(newAuthStatus: AuthStatus): void {
30-
if (([AuthStatusEnum.FAIL, AuthStatusEnum.SUCCESS] asstring[]).includes(newAuthStatus)) {
34+
public onStatusChange(newAuthStatus: AuthStatusEnum): void {
35+
if (this.authStatusEmitOnValues.includes(newAuthStatus)) {
3136
setTimeout(() => {
3237
this.$emit(newAuthStatus);
3338
}, this.delay);

‎GhostUI/ClientApp/src/components/Navbar.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ export default class Navbar extends Vue {
4141
return AuthModule.isAuthenticated;
4242
}
4343
44-
public navRoutes: Route[] = Object.keys(RoutesConfig).reduce((acc:Route[], key:string) => {
44+
public navRoutes: Route[] = Object.keys(RoutesConfig).reduce((acc, key) => {
4545
const route = RoutesConfig[key];
4646
route.meta.showInNav && acc.push(route);
4747
return acc;
48-
}, []);
48+
}, []asRoute[]);
4949
}
5050
</script>
5151

‎GhostUI/ClientApp/src/components/Settings.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@
5353
<script lang="ts">
5454
import { Component, Vue } from "vue-property-decorator";
5555
import { AuthModule } from "@/store/modules/auth";
56-
import { nugetUrlConfig } from "@/config/constants";
56+
import { NUGET_URL_CONFIG } from "@/config/constants";
5757
import { Route, RoutesConfig } from "@/config/routes.config";
5858
5959
@Component
6060
export default class Settings extends Vue {
6161
public open: boolean = false;
6262
63-
public readonly nugetUrls: Record<string, string> = nugetUrlConfig;
6463
public readonly routesConfig: Record<string, Route> = RoutesConfig;
64+
public readonly nugetUrls: Record<string, string> = NUGET_URL_CONFIG;
6565
6666
get isAuthenticated(): boolean {
6767
return AuthModule.isAuthenticated;
Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
1-
import axios, { AxiosError, AxiosResponse } from 'axios';
2-
import { EventBus } from '@/event-bus';
3-
4-
export default class AxiosGlobalConfig {
5-
public static setup(): void {
6-
axios.interceptors.response.use(
7-
(response: AxiosResponse) => {
8-
return response;
9-
},
10-
(error: AxiosError) => {
11-
handleAxiosError(error);
12-
return Promise.reject(error);
13-
}
14-
);
15-
}
16-
}
1+
import { EventBus } from '@/event-bus';
2+
import axios, { AxiosError, AxiosResponse } from 'axios';
173

184
const handleAxiosError = (error: AxiosError): void => {
195
// Error Message Object
@@ -23,25 +9,29 @@ const handleAxiosError = (error: AxiosError): void => {
239
status: 500
2410
};
2511

26-
//Setup Error Message
27-
if (typeof error !== 'undefined') {
28-
if (error.hasOwnProperty('message')) {
29-
message.body = error.message;
30-
}
12+
// Setup Error Message
13+
if (typeof error !== 'undefined' && error.hasOwnProperty('message')) {
14+
message.body = error.message;
3115
}
3216

3317
if (typeof error.response !== 'undefined') {
3418
// Setup Generic Response Messages
35-
if (error.response.status === 401) {
36-
message.body = 'UnAuthorized';
37-
} else if (error.response.status === 404) {
38-
message.body = 'API Route is Missing or Undefined';
39-
} else if (error.response.status === 405) {
40-
message.body = 'API Route Method Not Allowed';
41-
} else if (error.response.status === 422) {
42-
//Validation Message
43-
} else if (error.response.status >= 500) {
44-
message.body = 'Internal Server Error';
19+
switch (error.response.status) {
20+
case 401:
21+
message.body = 'UnAuthorized';
22+
break;
23+
case 404:
24+
message.body = 'API Route is Missing or Undefined';
25+
break;
26+
case 405:
27+
message.body = 'API Route Method Not Allowed';
28+
break;
29+
case 422:
30+
break;
31+
case 500:
32+
default:
33+
message.body = 'Internal Server Error';
34+
break;
4535
}
4636

4737
// Assign error status code
@@ -50,13 +40,34 @@ const handleAxiosError = (error: AxiosError): void => {
5040
}
5141

5242
// Try to Use the Response Message
53-
if (error.hasOwnProperty('response') && error.response.hasOwnProperty('data')) {
54-
if (error.response.data.hasOwnProperty('message') && error.response.data.message.length > 0) {
55-
message.body = error.response.data.message;
56-
}
43+
if (
44+
error.hasOwnProperty('response') &&
45+
error.response.hasOwnProperty('data') &&
46+
error.response.data.hasOwnProperty('message') &&
47+
!!error.response.data.message.length
48+
) {
49+
message.body = error.response.data.message;
5750
}
5851
}
5952

53+
6054
// Log in console or use Snotify notification (via Global EventBus)
61-
EventBus.$snotify.error(`${message.status} (${message.body})`, 'XHR Error');
55+
EventBus.$snotify.error(
56+
`${message.status} (${message.body})`,
57+
'XHR Error'
58+
);
6259
};
60+
61+
export default class AxiosGlobalConfig {
62+
public static setup(): void {
63+
axios.interceptors.response.use(
64+
(response: AxiosResponse) => {
65+
return response;
66+
},
67+
(error: AxiosError) => {
68+
handleAxiosError(error);
69+
return Promise.reject(error);
70+
}
71+
);
72+
}
73+
}

‎GhostUI/ClientApp/src/config/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export const DROPDOWN_TEST_DATA: IDropdownOption[] = [
1414
/**
1515
* HealthChecks/Swagger response path config
1616
*/
17-
export const nugetUrlConfig=Object.freeze<Record<string, string>>({
17+
export const NUGET_URL_CONFIG: Record<string, string>={
1818
HEALTH_UI: 'http://localhost:52530/healthchecks-ui',
1919
HEALTH_JSON: 'http://localhost:52530/healthchecks-json',
2020
SWAGGER_DOCS: 'http://localhost:52530/docs'
21-
});
21+
};

‎GhostUI/ClientApp/src/config/vue-snotify.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SnotifyPosition, SnotifyDefaults, SnotifyStyle } from 'vue-snotify';
22

3-
export const snotifyDefaults=Object.freeze<SnotifyDefaults>({
3+
export const snotifyDefaults: SnotifyDefaults={
44
global: {
55
newOnTop: true,
66
maxAtPosition: 4,
@@ -22,4 +22,4 @@ export const snotifyDefaults = Object.freeze<SnotifyDefaults>({
2222
timeout: 7500
2323
}
2424
}
25-
});
25+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /