Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CSAN
Csan
Commits
43c8e9f5
Commit
43c8e9f5
authored
May 14, 2018
by
Deng, Qian
Browse files
Fix all tslint warnings
1. Fix tslint warnings 2. Add tslint to travis
parent
44006247
Changes
236
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
698 additions
and
679 deletions
+698
-679
src/replication/core/controller.go
src/replication/core/controller.go
+1
-1
src/ui_ng/lib/index.ts
src/ui_ng/lib/index.ts
+1
-1
src/ui_ng/lib/package.json
src/ui_ng/lib/package.json
+1
-1
src/ui_ng/lib/src/channel/channel.service.ts
src/ui_ng/lib/src/channel/channel.service.ts
+3
-2
src/ui_ng/lib/src/channel/index.ts
src/ui_ng/lib/src/channel/index.ts
+1
-1
src/ui_ng/lib/src/config/config.ts
src/ui_ng/lib/src/config/config.ts
+1
-1
src/ui_ng/lib/src/config/index.ts
src/ui_ng/lib/src/config/index.ts
+1
-1
src/ui_ng/lib/src/config/registry-config.component.spec.ts
src/ui_ng/lib/src/config/registry-config.component.spec.ts
+1
-1
src/ui_ng/lib/src/config/registry-config.component.ts
src/ui_ng/lib/src/config/registry-config.component.ts
+25
-30
src/ui_ng/lib/src/config/replication/replication-config.component.ts
...ib/src/config/replication/replication-config.component.ts
+2
-2
src/ui_ng/lib/src/config/system/system-settings.component.ts
src/ui_ng/lib/src/config/system/system-settings.component.ts
+1
-1
src/ui_ng/lib/src/config/vulnerability/vulnerability-config.component.ts
...rc/config/vulnerability/vulnerability-config.component.ts
+18
-18
src/ui_ng/lib/src/confirmation-dialog/confirmation-message.ts
...ui_ng/lib/src/confirmation-dialog/confirmation-message.ts
+26
-16
src/ui_ng/lib/src/confirmation-dialog/confirmation-state-message.ts
...lib/src/confirmation-dialog/confirmation-state-message.ts
+1
-1
src/ui_ng/lib/src/confirmation-dialog/index.ts
src/ui_ng/lib/src/confirmation-dialog/index.ts
+3
-3
src/ui_ng/lib/src/create-edit-endpoint/create-edit-endpoint.component.spec.ts
...eate-edit-endpoint/create-edit-endpoint.component.spec.ts
+41
-37
src/ui_ng/lib/src/create-edit-endpoint/create-edit-endpoint.component.ts
...rc/create-edit-endpoint/create-edit-endpoint.component.ts
+331
-335
src/ui_ng/lib/src/create-edit-endpoint/index.ts
src/ui_ng/lib/src/create-edit-endpoint/index.ts
+1
-1
src/ui_ng/lib/src/create-edit-label/create-edit-label.component.spec.ts
...src/create-edit-label/create-edit-label.component.spec.ts
+74
-75
src/ui_ng/lib/src/create-edit-label/create-edit-label.component.ts
.../lib/src/create-edit-label/create-edit-label.component.ts
+165
-151
No files found.
src/replication/core/controller.go
View file @
43c8e9f5
...
...
@@ -208,7 +208,7 @@ func (ctl *DefaultController) Replicate(policyID int64, metadata ...map[string]i
// prepare candidates for replication
candidates
:=
getCandidates
(
&
policy
,
ctl
.
sourcer
,
metadata
...
)
if
len
(
candidates
)
==
0
{
log
.
Debugf
(
"replicaton candidates are null, no further action needed"
)
log
.
Debugf
(
"replicat
i
on candidates are null, no further action needed"
)
}
targets
:=
[]
*
common_models
.
RepTarget
{}
...
...
src/ui_ng/lib/index.ts
View file @
43c8e9f5
export
*
from
'
./src/index
'
;
\ No newline at end of file
export
*
from
'
./src/index
'
;
src/ui_ng/lib/package.json
View file @
43c8e9f5
{
"name"
:
"harbor-ui"
,
"version"
:
"0.7.18-dev.
6
"
,
"version"
:
"0.7.18-dev.
8
"
,
"description"
:
"Harbor shared UI components based on Clarity and Angular4"
,
"author"
:
"VMware"
,
"module"
:
"index.js"
,
...
...
src/ui_ng/lib/src/channel/channel.service.ts
View file @
43c8e9f5
...
...
@@ -13,16 +13,17 @@
// limitations under the License.
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Subject
}
from
'
rxjs/Subject
'
;
// tslint:disable-next-line:no-unused-variable
import
{
Observable
}
from
"
rxjs/Observable
"
;
@
Injectable
()
export
class
ChannelService
{
//Declare for publishing scan event
//
Declare for publishing scan event
scanCommandSource
=
new
Subject
<
string
>
();
scanCommand$
=
this
.
scanCommandSource
.
asObservable
();
publishScanEvent
(
tagId
:
string
):
void
{
this
.
scanCommandSource
.
next
(
tagId
);
}
}
\ No newline at end of file
}
src/ui_ng/lib/src/channel/index.ts
View file @
43c8e9f5
export
*
from
'
./channel.service
'
;
\ No newline at end of file
export
*
from
'
./channel.service
'
;
src/ui_ng/lib/src/config/config.ts
View file @
43c8e9f5
...
...
@@ -119,4 +119,4 @@ export class Configuration {
},
true
);
this
.
read_only
=
new
BoolValueItem
(
false
,
true
);
}
}
\ No newline at end of file
}
src/ui_ng/lib/src/config/index.ts
View file @
43c8e9f5
...
...
@@ -16,4 +16,4 @@ export const CONFIGURATION_DIRECTIVES: Type<any>[] = [
SystemSettingsComponent
,
VulnerabilityConfigComponent
,
RegistryConfigComponent
];
\ No newline at end of file
];
src/ui_ng/lib/src/config/registry-config.component.spec.ts
View file @
43c8e9f5
...
...
@@ -114,4 +114,4 @@ describe('RegistryConfigComponent (inline template)', () => {
expect
(
saveSpy
.
calls
.
any
).
toBeTruthy
();
}));
});
\ No newline at end of file
});
src/ui_ng/lib/src/config/registry-config.component.ts
View file @
43c8e9f5
import
{
Component
,
OnInit
,
EventEmitter
,
Output
,
ViewChild
,
Input
}
from
'
@angular/core
'
;
import
{
Component
,
OnInit
,
ViewChild
,
Input
}
from
'
@angular/core
'
;
import
{
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
Configuration
,
ComplexValueItem
}
from
'
./config
'
;
import
{
ConfigurationService
,
SystemInfoService
,
SystemInfo
,
ClairDBStatus
}
from
'
../service/index
'
;
import
{
ConfirmationState
,
ConfirmationTargets
}
from
'
../shared/shared.const
'
;
import
{
ConfirmationDialogComponent
}
from
'
../confirmation-dialog/confirmation-dialog.component
'
;
import
{
ConfirmationMessage
}
from
'
../confirmation-dialog/confirmation-message
'
;
import
{
ConfirmationAcknowledgement
}
from
'
../confirmation-dialog/confirmation-state-message
'
;
import
{
ConfigurationService
,
SystemInfoService
,
SystemInfo
}
from
'
../service/index
'
;
import
{
toPromise
,
compareValue
,
...
...
@@ -9,17 +13,8 @@ import {
clone
}
from
'
../utils
'
;
import
{
ErrorHandler
}
from
'
../error-handler/index
'
;
import
{
SystemSettingsComponent
,
VulnerabilityConfigComponent
}
from
'
./index
'
;
import
{
ConfirmationState
,
ConfirmationTargets
,
ConfirmationButtons
}
from
'
../shared/shared.const
'
;
import
{
ConfirmationDialogComponent
}
from
'
../confirmation-dialog/confirmation-dialog.component
'
;
import
{
ConfirmationMessage
}
from
'
../confirmation-dialog/confirmation-message
'
;
import
{
ConfirmationAcknowledgement
}
from
'
../confirmation-dialog/confirmation-state-message
'
;
import
{
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
SystemSettingsComponent
,
VulnerabilityConfigComponent
}
from
'
./index
'
;
import
{
Configuration
}
from
'
./config
'
;
@
Component
({
selector
:
'
hbr-registry-config
'
,
...
...
@@ -62,7 +57,7 @@ export class RegistryConfigComponent implements OnInit {
ngOnInit
():
void
{
this
.
loadSystemInfo
();
//Initialize
//
Initialize
this
.
load
();
}
...
...
@@ -77,14 +72,14 @@ export class RegistryConfigComponent implements OnInit {
return
!
isEmptyObject
(
this
.
getChanges
());
}
//Get system info
//
Get system info
loadSystemInfo
():
void
{
toPromise
<
SystemInfo
>
(
this
.
systemInfoService
.
getSystemInfo
())
.
then
((
info
:
SystemInfo
)
=>
this
.
systemInfo
=
info
)
.
catch
(
error
=>
this
.
errorHandler
.
error
(
error
));
}
//Load configurations
//
Load configurations
load
():
void
{
this
.
onGoing
=
true
;
toPromise
<
Configuration
>
(
this
.
configService
.
getConfigurations
())
...
...
@@ -99,12 +94,12 @@ export class RegistryConfigComponent implements OnInit {
});
}
//Save configuration changes
//
Save configuration changes
save
():
void
{
let
changes
:
{
[
key
:
string
]:
any
|
any
[]
}
=
this
.
getChanges
();
if
(
isEmptyObject
(
changes
))
{
//Guard code, do nothing
//
Guard code, do nothing
return
;
}
...
...
@@ -116,10 +111,10 @@ export class RegistryConfigComponent implements OnInit {
this
.
translate
.
get
(
"
CONFIG.SAVE_SUCCESS
"
).
subscribe
((
res
:
string
)
=>
{
this
.
errorHandler
.
info
(
res
);
});
//Reload to fetch all the updates
//
Reload to fetch all the updates
this
.
load
();
//Reload all system info
//this.loadSystemInfo();
//
Reload all system info
//
this.loadSystemInfo();
})
.
catch
(
error
=>
{
this
.
onGoing
=
false
;
...
...
@@ -127,7 +122,7 @@ export class RegistryConfigComponent implements OnInit {
});
}
//Cancel the changes if have
//
Cancel the changes if have
cancel
():
void
{
let
msg
=
new
ConfirmationMessage
(
"
CONFIG.CONFIRM_TITLE
"
,
...
...
@@ -139,7 +134,7 @@ export class RegistryConfigComponent implements OnInit {
this
.
confirmationDlg
.
open
(
msg
);
}
//Confirm cancel
//
Confirm cancel
confirmCancel
(
ack
:
ConfirmationAcknowledgement
):
void
{
if
(
ack
&&
ack
.
source
===
ConfirmationTargets
.
CONFIG
&&
ack
.
state
===
ConfirmationState
.
CONFIRMED
)
{
...
...
@@ -148,9 +143,9 @@ export class RegistryConfigComponent implements OnInit {
}
reset
():
void
{
//Reset to the values of copy
//
Reset to the values of copy
let
changes
:
{
[
key
:
string
]:
any
|
any
[]
}
=
this
.
getChanges
();
for
(
let
prop
in
changes
)
{
for
(
let
prop
of
Object
.
keys
(
changes
)
)
{
this
.
config
[
prop
]
=
clone
(
this
.
configCopy
[
prop
]);
}
}
...
...
@@ -161,17 +156,17 @@ export class RegistryConfigComponent implements OnInit {
return
changes
;
}
for
(
let
prop
in
this
.
config
)
{
for
(
let
prop
of
Object
.
keys
(
this
.
config
)
)
{
let
field
=
this
.
configCopy
[
prop
];
if
(
field
&&
field
.
editable
)
{
if
(
!
compareValue
(
field
.
value
,
this
.
config
[
prop
].
value
))
{
changes
[
prop
]
=
this
.
config
[
prop
].
value
;
//Number
//
Number
if
(
typeof
field
.
value
===
"
number
"
)
{
changes
[
prop
]
=
+
changes
[
prop
];
}
//Trim string value
//
Trim string value
if
(
typeof
field
.
value
===
"
string
"
)
{
changes
[
prop
]
=
(
''
+
changes
[
prop
]).
trim
();
}
...
...
@@ -181,4 +176,4 @@ export class RegistryConfigComponent implements OnInit {
return
changes
;
}
}
\ No newline at end of file
}
src/ui_ng/lib/src/config/replication/replication-config.component.ts
View file @
43c8e9f5
...
...
@@ -21,7 +21,7 @@ export class ReplicationConfigComponent {
this
.
configChange
.
emit
(
this
.
config
);
}
@
Input
()
showSubTitle
:
boolean
=
false
@
Input
()
showSubTitle
:
boolean
=
false
;
@
ViewChild
(
"
replicationConfigFrom
"
)
replicationConfigForm
:
NgForm
;
...
...
@@ -34,4 +34,4 @@ export class ReplicationConfigComponent {
get
isValid
():
boolean
{
return
this
.
replicationConfigForm
&&
this
.
replicationConfigForm
.
valid
;
}
}
\ No newline at end of file
}
src/ui_ng/lib/src/config/system/system-settings.component.ts
View file @
43c8e9f5
...
...
@@ -53,4 +53,4 @@ export class SystemSettingsComponent {
this
.
downloadLink
=
this
.
configInfo
.
systemInfoEndpoint
+
"
/getcert
"
;
}
}
}
\ No newline at end of file
}
src/ui_ng/lib/src/config/vulnerability/vulnerability-config.component.ts
View file @
43c8e9f5
...
...
@@ -10,7 +10,7 @@ import {
import
{
ErrorHandler
}
from
'
../../error-handler/index
'
;
import
{
toPromise
}
from
'
../../utils
'
;
import
{
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
ClairDBStatus
,
ClairDetail
}
from
'
../../service/interface
'
;
import
{
ClairDetail
}
from
'
../../service/interface
'
;
const
ONE_HOUR_SECONDS
:
number
=
3600
;
const
ONE_DAY_SECONDS
:
number
=
24
*
ONE_HOUR_SECONDS
;
...
...
@@ -85,7 +85,7 @@ export class VulnerabilityConfigComponent implements OnInit {
return
[];
}
//UTC time
//
UTC time
get
dailyTime
():
string
{
if
(
!
(
this
.
config
&&
this
.
config
.
scan_all_policy
&&
...
...
@@ -94,7 +94,7 @@ export class VulnerabilityConfigComponent implements OnInit {
return
"
00:00
"
;
}
let
timeOffset
:
number
=
0
;
//seconds
let
timeOffset
:
number
=
0
;
//
seconds
if
(
this
.
config
.
scan_all_policy
.
value
.
parameter
)
{
let
daily_time
=
this
.
config
.
scan_all_policy
.
value
.
parameter
.
daily_time
;
if
(
daily_time
&&
typeof
daily_time
===
"
number
"
)
{
...
...
@@ -102,9 +102,9 @@ export class VulnerabilityConfigComponent implements OnInit {
}
}
//Convert to current time
//
Convert to current time
let
timezoneOffset
:
number
=
this
.
_localTime
.
getTimezoneOffset
();
//Local time
//
Local time
timeOffset
=
timeOffset
-
timezoneOffset
*
60
;
if
(
timeOffset
<
0
)
{
timeOffset
=
timeOffset
+
ONE_DAY_SECONDS
;
...
...
@@ -114,7 +114,7 @@ export class VulnerabilityConfigComponent implements OnInit {
timeOffset
-=
ONE_DAY_SECONDS
;
}
//To time string
//
To time string
let
hours
:
number
=
Math
.
floor
(
timeOffset
/
ONE_HOUR_SECONDS
);
let
minutes
:
number
=
Math
.
floor
((
timeOffset
-
hours
*
ONE_HOUR_SECONDS
)
/
60
);
...
...
@@ -143,7 +143,7 @@ export class VulnerabilityConfigComponent implements OnInit {
return
;
}
//Double confirm inner parameter existing.
//
Double confirm inner parameter existing.
if
(
!
this
.
config
.
scan_all_policy
.
value
.
parameter
)
{
this
.
config
.
scan_all_policy
.
value
.
parameter
=
{
daily_time
:
0
...
...
@@ -157,7 +157,7 @@ export class VulnerabilityConfigComponent implements OnInit {
let
hours
:
number
=
+
values
[
0
];
let
minutes
:
number
=
+
values
[
1
];
//Convert to UTC time
//
Convert to UTC time
let
timezoneOffset
:
number
=
this
.
_localTime
.
getTimezoneOffset
();
let
utcTimes
:
number
=
hours
*
ONE_HOUR_SECONDS
+
minutes
*
60
;
utcTimes
+=
timezoneOffset
*
60
;
...
...
@@ -172,14 +172,14 @@ export class VulnerabilityConfigComponent implements OnInit {
this
.
config
.
scan_all_policy
.
value
.
parameter
.
daily_time
=
utcTimes
;
}
//Scanning type
//
Scanning type
get
scanningType
():
string
{
if
(
this
.
config
&&
this
.
config
.
scan_all_policy
&&
this
.
config
.
scan_all_policy
.
value
)
{
return
this
.
config
.
scan_all_policy
.
value
.
type
;
}
else
{
//default
//
default
return
"
none
"
;
}
}
...
...
@@ -191,12 +191,12 @@ export class VulnerabilityConfigComponent implements OnInit {
let
type
:
string
=
(
v
&&
v
.
trim
()
!==
""
)
?
v
:
"
none
"
;
this
.
config
.
scan_all_policy
.
value
.
type
=
type
;
if
(
type
!==
"
daily
"
)
{
//No parameter
//
No parameter
if
(
this
.
config
.
scan_all_policy
.
value
.
parameter
)
{
delete
(
this
.
config
.
scan_all_policy
.
value
.
parameter
);
}
}
else
{
//Has parameter
//
Has parameter
if
(
!
this
.
config
.
scan_all_policy
.
value
.
parameter
)
{
this
.
config
.
scan_all_policy
.
value
.
parameter
=
{
daily_time
:
0
...
...
@@ -251,11 +251,11 @@ export class VulnerabilityConfigComponent implements OnInit {
scanNow
():
void
{
if
(
this
.
onSubmitting
)
{
return
;
//Aoid duplicated submitting
return
;
//
Aoid duplicated submitting
}
if
(
!
this
.
scanAvailable
)
{
return
;
//Aoid page hacking
if
(
!
this
.
scanAvailable
)
{
return
;
//
Aoid page hacking
}
this
.
onSubmitting
=
true
;
...
...
@@ -265,7 +265,7 @@ export class VulnerabilityConfigComponent implements OnInit {
this
.
errorHandler
.
info
(
res
);
});
//Update system info
//
Update system info
this
.
getSystemInfo
().
then
(()
=>
{
this
.
onSubmitting
=
false
;
}).
catch
(()
=>
{
...
...
@@ -284,9 +284,9 @@ export class VulnerabilityConfigComponent implements OnInit {
});
}
getSystemInfo
():
Promise
<
SystemInfo
>
{
getSystemInfo
():
Promise
<
void
|
SystemInfo
>
{
return
toPromise
<
SystemInfo
>
(
this
.
systemInfoService
.
getSystemInfo
())
.
then
((
info
:
SystemInfo
)
=>
this
.
systemInfo
=
info
)
.
catch
(
error
=>
this
.
errorHandler
.
error
(
error
));
}
}
\ No newline at end of file
}
src/ui_ng/lib/src/confirmation-dialog/confirmation-message.ts
View file @
43c8e9f5
...
...
@@ -11,21 +11,31 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import
{
ConfirmationTargets
,
ConfirmationButtons
}
from
'
../shared/shared.const
'
;
import
{
ConfirmationTargets
,
ConfirmationButtons
}
from
"
../shared/shared.const
"
;
export
class
ConfirmationMessage
{
public
constructor
(
title
:
string
,
message
:
string
,
param
:
string
,
data
:
any
,
targetId
:
ConfirmationTargets
,
buttons
?:
ConfirmationButtons
)
{
this
.
title
=
title
;
this
.
message
=
message
;
this
.
data
=
data
;
this
.
targetId
=
targetId
;
this
.
param
=
param
;
this
.
buttons
=
buttons
?
buttons
:
ConfirmationButtons
.
CONFIRM_CANCEL
;
}
title
:
string
;
message
:
string
;
data
:
any
=
{};
//default is empty
targetId
:
ConfirmationTargets
=
ConfirmationTargets
.
EMPTY
;
param
:
string
;
buttons
:
ConfirmationButtons
;
}
\ No newline at end of file
public
constructor
(
title
:
string
,
message
:
string
,
param
:
string
,
data
:
any
,
targetId
:
ConfirmationTargets
,
buttons
?:
ConfirmationButtons
)
{
this
.
title
=
title
;
this
.
message
=
message
;
this
.
data
=
data
;
this
.
targetId
=
targetId
;
this
.
param
=
param
;
this
.
buttons
=
buttons
?
buttons
:
ConfirmationButtons
.
CONFIRM_CANCEL
;
}
title
:
string
;
message
:
string
;
data
:
any
=
{};
// default is empty
targetId
:
ConfirmationTargets
=
ConfirmationTargets
.
EMPTY
;
param
:
string
;
buttons
:
ConfirmationButtons
;
}
src/ui_ng/lib/src/confirmation-dialog/confirmation-state-message.ts
View file @
43c8e9f5
...
...
@@ -23,4 +23,4 @@ export class ConfirmationAcknowledgement {
state
:
ConfirmationState
=
ConfirmationState
.
NA
;
data
:
any
=
{};
source
:
ConfirmationTargets
=
ConfirmationTargets
.
EMPTY
;
}
\ No newline at end of file
}
src/ui_ng/lib/src/confirmation-dialog/index.ts
View file @
43c8e9f5
import
{
Type
}
from
'
@angular/core
'
;
import
{
Type
}
from
"
@angular/core
"
;
import
{
ConfirmationDialogComponent
}
from
'
./confirmation-dialog.component
'
;
import
{
ConfirmationDialogComponent
}
from
"
./confirmation-dialog.component
"
;
export
*
from
"
./confirmation-dialog.component
"
;
export
*
from
"
./confirmation-batch-message
"
;
...
...
@@ -9,4 +9,4 @@ export * from "./confirmation-state-message";
export
const
CONFIRMATION_DIALOG_DIRECTIVES
:
Type
<
any
>
[]
=
[
ConfirmationDialogComponent
];
\ No newline at end of file
];
src/ui_ng/lib/src/create-edit-endpoint/create-edit-endpoint.component.spec.ts
View file @
43c8e9f5
import
{
ComponentFixture
,
TestBed
,
async
,
fakeAsync
,
tick
}
from
'
@angular/core/testing
'
;
import
{
ComponentFixture
,
TestBed
,
async
}
from
"
@angular/core/testing
"
;
import
{
NoopAnimationsModule
}
from
"
@angular/platform-browser/animations
"
;
import
{
By
}
from
'
@angular/platform-browser
'
;
import
{
DebugElement
}
from
'
@angular/core
'
;
import
{
SharedModule
}
from
'
../shared/shared.module
'
;
import
{
SharedModule
}
from
"
../shared/shared.module
"
;
import
{
FilterComponent
}
from
'
../filter/filter.component
'
;
import
{
CreateEditEndpointComponent
}
from
'
../create-edit-endpoint/create-edit-endpoint.component
'
;
import
{
InlineAlertComponent
}
from
'
../inline-alert/inline-alert.component
'
;
import
{
ErrorHandler
}
from
'
../error-handler/error-handler
'
;
import
{
Endpoint
}
from
'
../service/interface
'
;
import
{
EndpointService
,
EndpointDefaultService
}
from
'
../service/endpoint.service
'
;
import
{
IServiceConfig
,
SERVICE_CONFIG
}
from
'
../service.config
'
;
describe
(
'
CreateEditEndpointComponent (inline template)
'
,
()
=>
{
import
{
FilterComponent
}
from
"
../filter/filter.component
"
;
import
{
CreateEditEndpointComponent
}
from
"
../create-edit-endpoint/create-edit-endpoint.component
"
;
import
{
InlineAlertComponent
}
from
"
../inline-alert/inline-alert.component
"
;
import
{
ErrorHandler
}
from
"
../error-handler/error-handler
"
;
import
{
Endpoint
}
from
"
../service/interface
"
;
import
{
EndpointService
,
EndpointDefaultService
}
from
"
../service/endpoint.service
"
;
import
{
IServiceConfig
,
SERVICE_CONFIG
}
from
"
../service.config
"
;
describe
(
"
CreateEditEndpointComponent (inline template)
"
,
()
=>
{
let
mockData
:
Endpoint
=
{
"
id
"
:
1
,
"
endpoint
"
:
"
https://10.117.4.151
"
,
"
name
"
:
"
target_01
"
,
"
username
"
:
"
admin
"
,
"
password
"
:
""
,
"
insecure
"
:
false
,
"
type
"
:
0
id
:
1
,
endpoint
:
"
https://10.117.4.151
"
,
name
:
"
target_01
"
,
username
:
"
admin
"
,
password
:
""
,
insecure
:
false
,
type
:
0
};
let
comp
:
CreateEditEndpointComponent
;
let
fixture
:
ComponentFixture
<
CreateEditEndpointComponent
>
;
let
config
:
IServiceConfig
=
{
systemInfoEndpoint
:
'
/api/endpoints/testing
'
systemInfoEndpoint
:
"
/api/endpoints/testing
"
};
let
endpointService
:
EndpointService
;
...
...
@@ -38,14 +42,12 @@ describe('CreateEditEndpointComponent (inline template)', () => {
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
imports
:
[
SharedModule
,
NoopAnimationsModule
imports
:
[
SharedModule
,
NoopAnimationsModule
],
declarations
:
[
FilterComponent
,
CreateEditEndpointComponent
,
InlineAlertComponent
],
declarations
:
[
FilterComponent
,
CreateEditEndpointComponent
,
InlineAlertComponent
],
providers
:
[
ErrorHandler
,
{
provide
:
SERVICE_CONFIG
,
useValue
:
config
},
...
...
@@ -54,24 +56,26 @@ describe('CreateEditEndpointComponent (inline template)', () => {
});
}));
beforeEach
(()
=>
{
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
CreateEditEndpointComponent
);
comp
=
fixture
.
componentInstance
;
endpointService
=
fixture
.
debugElement
.
injector
.
get
(
EndpointService
);
spy
=
spyOn
(
endpointService
,
'
getEndpoint
'
).
and
.
returnValue
(
Promise
.
resolve
(
mockData
));
spy
=
spyOn
(
endpointService
,
"
getEndpoint
"
).
and
.
returnValue
(
Promise
.
resolve
(
mockData
)
);
fixture
.
detectChanges
();
comp
.
openCreateEditTarget
(
true
,
1
);
fixture
.
detectChanges
();
});
it
(
'
should be created
'
,
()
=>
{
it
(
"
should be created
"
,
()
=>
{
fixture
.
detectChanges
();
expect
(
comp
).
toBeTruthy
();
});
it
(
'
should get endpoint be called
'
,
async
(()
=>
{
it
(
"
should get endpoint be called
"
,
async
(()
=>
{
fixture
.
detectChanges
();
fixture
.
whenStable
().
then
(()
=>
{
fixture
.
detectChanges
();
...
...
@@ -79,16 +83,16 @@ describe('CreateEditEndpointComponent (inline template)', () => {
});
}));
it
(
'
should get endpoint and open modal
'
,
async
(()
=>
{
it
(
"
should get endpoint and open modal
"
,
async
(()
=>
{
fixture
.
detectChanges
();
fixture
.
whenStable
().
then
(()
=>
{
fixture
.
detectChanges
();
expect
(
comp
.
target
.
name
).
toEqual
(
'
target_01
'
);
expect
(
comp
.
target
.
name
).
toEqual
(
"
target_01
"
);
});
}));
it
(
'
should endpoint be initialized
'
,
()
=>
{
it
(
"
should endpoint be initialized
"
,
()
=>
{
fixture
.
detectChanges
();
expect
(
config
.
systemInfoEndpoint
).
toEqual
(
'
/api/endpoints/testing
'
);
expect
(
config
.
systemInfoEndpoint
).
toEqual
(
"
/api/endpoints/testing
"
);
});
});
\ No newline at end of file
});
src/ui_ng/lib/src/create-edit-endpoint/create-edit-endpoint.component.ts
View file @
43c8e9f5
This diff is collapsed.
Click to expand it.
src/ui_ng/lib/src/create-edit-endpoint/index.ts
View file @
43c8e9f5
...
...
@@ -4,4 +4,4 @@ import { CreateEditEndpointComponent } from './create-edit-endpoint.component';
export
const
CREATE_EDIT_ENDPOINT_DIRECTIVES
:
Type
<
any
>
[]
=
[
CreateEditEndpointComponent
];
\ No newline at end of file
];
src/ui_ng/lib/src/create-edit-label/create-edit-label.component.spec.ts
View file @
43c8e9f5
import
{
ComponentFixture
,
TestBed
,
async
}
from
'
@angular/core/testing
'
;
import
{
ComponentFixture
,
TestBed
,
async
}
from
"
@angular/core/testing
"
;
import
{
NoopAnimationsModule
}
from
"
@angular/platform-browser/animations
"
;
import
{
SharedModule
}
from
'
../shared/shared.module
'
;
import
{
FilterComponent
}
from
'
../filter/filter.component
'
;