mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 04:05:40 +01:00
Merge branch 'master' into replication_ng
Signed-off-by: Meina Zhou <meinaz@vmware.com>
This commit is contained in:
commit
130e132f86
@ -65,7 +65,7 @@ These Basic Configuration must be set. Otherwise you can't deploy Harbor on Kube
|
||||
path: /data/registry
|
||||
```
|
||||
|
||||
For more infomation about storage solution, Please check [Kubernetes Document](http://kubernetes.io/docs/user-guide/persistent-volumes/)
|
||||
For more information about storage solution, Please check [Kubernetes Document](http://kubernetes.io/docs/user-guide/persistent-volumes/)
|
||||
|
||||
Then you can generate ConfigMap files by :
|
||||
|
||||
|
@ -156,7 +156,7 @@ paths:
|
||||
description: Unexpected internal errors.
|
||||
'/projects/{project_id}':
|
||||
get:
|
||||
summary: Return specific project detail infomation
|
||||
summary: Return specific project detail information
|
||||
description: |
|
||||
This endpoint returns specific project information by project ID.
|
||||
parameters:
|
||||
@ -707,7 +707,7 @@ paths:
|
||||
get:
|
||||
summary: Get current user info.
|
||||
description: |
|
||||
This endpoint is to get the current user infomation.
|
||||
This endpoint is to get the current user information.
|
||||
tags:
|
||||
- Products
|
||||
responses:
|
||||
@ -1409,7 +1409,7 @@ paths:
|
||||
post:
|
||||
summary: Scan all images of the registry.
|
||||
description: |
|
||||
The server will launch different jobs to scan each image on the regsitry, so this is equivalent to calling the API to scan the image one by one in background, so there's no way to track the overall status of the "scan all" action. Only system adim has permission to call this API.
|
||||
The server will launch different jobs to scan each image on the regisitry, so this is equivalent to calling the API to scan the image one by one in background, so there's no way to track the overall status of the "scan all" action. Only system adim has permission to call this API.
|
||||
parameters:
|
||||
- name: project_id
|
||||
in: query
|
||||
@ -5180,7 +5180,7 @@ definitions:
|
||||
description:
|
||||
type: string
|
||||
description: The description of robot account
|
||||
expiresat:
|
||||
expires_at:
|
||||
type: integer
|
||||
description: The expiration of robot account (in seconds)
|
||||
project_id:
|
||||
|
@ -14,7 +14,7 @@ RUN tdnf install -y shadow gzip postgresql >> /dev/null\
|
||||
&& sed -i "s|#unix_socket_directories = '/tmp'.*|unix_socket_directories = '/run/postgresql'|g" /usr/share/postgresql/postgresql.conf.sample \
|
||||
&& tdnf clean all
|
||||
|
||||
RUN tdnf erase -y toybox && tdnf install -y util-linux
|
||||
RUN tdnf erase -y toybox && tdnf install -y util-linux net-tools
|
||||
|
||||
VOLUME /var/lib/postgresql/data
|
||||
|
||||
|
193
src/Gopkg.lock
generated
193
src/Gopkg.lock
generated
@ -2,44 +2,57 @@
|
||||
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b16fbfbcc20645cb419f78325bb2e85ec729b338e996a228124d68931a6f2a37"
|
||||
name = "github.com/BurntSushi/toml"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "b26d9c308763d68093482582cea63d69be07a0f0"
|
||||
version = "v0.3.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:5d3e23515e7916c152cc665eda0f7eaf6fdf8fdfe7c3dbac97049bcbd649b33f"
|
||||
name = "github.com/Knetic/govaluate"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "d216395917cc49052c7c7094cf57f09657ca08a8"
|
||||
version = "v3.0.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:55388fd080150b9a072912f97b1f5891eb0b50df43401f8b75fb4273d3fec9fc"
|
||||
name = "github.com/Masterminds/semver"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "c7af12943936e8c39859482e61f0574c2fd7fc75"
|
||||
version = "v1.4.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:9e9193aa51197513b3abcb108970d831fbcf40ef96aa845c4f03276e1fa316d2"
|
||||
name = "github.com/Sirupsen/logrus"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc"
|
||||
version = "v1.0.5"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:e8078e5f9d84e87745efb3c0961e78045500cda10d7102fdf839fbac4b49a423"
|
||||
name = "github.com/Unknwon/goconfig"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "5f601ca6ef4d5cea8d52be2f8b3a420ee4b574a5"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:47ea4fbe2ab4aeb9808502c51e657041c2e49b36b83fc1c1a349135cdf16342f"
|
||||
name = "github.com/agl/ed25519"
|
||||
packages = [
|
||||
".",
|
||||
"edwards25519"
|
||||
"edwards25519",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "5312a61534124124185d41f09206b9fef1d88403"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:d2dbd0b0ec5373e89b27d0dd9f59793aa47020a05805b4b75c63aa1b2406781b"
|
||||
name = "github.com/astaxie/beego"
|
||||
packages = [
|
||||
".",
|
||||
@ -55,17 +68,21 @@
|
||||
"session/redis",
|
||||
"toolbox",
|
||||
"utils",
|
||||
"validation"
|
||||
"validation",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "d96289a81bf67728cff7a19b067aaecc65a62ec6"
|
||||
version = "v1.9.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:4522bd966f53adb3da34201b39df1153534e441c8067d5e674964f05ecca3a71"
|
||||
name = "github.com/beego/i18n"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "e87155e8f0c05bf323d0b13470e1b97af0cb5652"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:76ca0dfcbf951d1868c7449453981dba9e1f79034706d1500a5a785000f5f222"
|
||||
name = "github.com/casbin/casbin"
|
||||
packages = [
|
||||
".",
|
||||
@ -77,60 +94,76 @@
|
||||
"persist/file-adapter",
|
||||
"rbac",
|
||||
"rbac/default-role-manager",
|
||||
"util"
|
||||
"util",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "542e16cac74562eefac970a7d0d1467640d1f1cb"
|
||||
version = "v1.7.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:a2c1d0e43bd3baaa071d1b9ed72c27d78169b2b269f71c105ac4ba34b1be4a39"
|
||||
name = "github.com/davecgh/go-spew"
|
||||
packages = ["spew"]
|
||||
pruneopts = "UT"
|
||||
revision = "346938d642f2ec3594ed81d874461961cd0faa76"
|
||||
version = "v1.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ace1aef6acdf2c4647365dc87c14fb8b71ed8bb0b3ae114ffb216614a24da219"
|
||||
name = "github.com/dghubble/sling"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "eb56e89ac5088bebb12eef3cb4b293300f43608b"
|
||||
version = "v1.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:d912bf9afc98bbb6539ea99c9ac3e83119853310dd1a3aec1583d76f340ece27"
|
||||
name = "github.com/dgrijalva/jwt-go"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "d2709f9f1f31ebcda9651b03077758c1f3a0018c"
|
||||
version = "v3.0.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:5a39bab16f84dd753a3af60076a915b55584cc6df3b3dfba53bfd48bf4420e77"
|
||||
name = "github.com/docker/distribution"
|
||||
packages = [
|
||||
".",
|
||||
"context",
|
||||
"digest",
|
||||
"health",
|
||||
"manifest",
|
||||
"manifest/schema1",
|
||||
"manifest/schema2",
|
||||
"reference",
|
||||
"registry/api/errcode",
|
||||
"registry/auth",
|
||||
"registry/auth/token",
|
||||
"registry/client/auth/challenge",
|
||||
"uuid"
|
||||
"uuid",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "48294d928ced5dd9b378f7fd7c6f5da3ff3f2c89"
|
||||
version = "v2.6.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:72ba344e60095ac4fe0eac56f56fe95644421670b808238a1c849ea92721037e"
|
||||
name = "github.com/docker/go"
|
||||
packages = ["canonical/json"]
|
||||
pruneopts = "UT"
|
||||
revision = "d30aec9fd63c35133f8f79c3412ad91a3b08be06"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:4841e14252a2cecf11840bd05230412ad469709bbacfc12467e2ce5ad07f339b"
|
||||
name = "github.com/docker/libtrust"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "aabc10ec26b754e797f9028f4589c5b7bd90dc20"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:fea1a444386b05e00dfcf2cb9a95fb09e11f1689056161471229baa4a7a65459"
|
||||
name = "github.com/docker/notary"
|
||||
packages = [
|
||||
".",
|
||||
@ -145,32 +178,40 @@
|
||||
"tuf/data",
|
||||
"tuf/signed",
|
||||
"tuf/utils",
|
||||
"tuf/validation"
|
||||
"tuf/validation",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "c04e3e6d05881045def11167c51d4a8baa34899a"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:0594af97b2f4cec6554086eeace6597e20a4b69466eb4ada25adf9f4300dddd2"
|
||||
name = "github.com/garyburd/redigo"
|
||||
packages = [
|
||||
"internal",
|
||||
"redis"
|
||||
"redis",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "a69d19351219b6dd56f274f96d85a7014a2ec34e"
|
||||
version = "v1.6.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:2cd7915ab26ede7d95b8749e6b1f933f1c6d5398030684e6505940a10f31cfda"
|
||||
name = "github.com/ghodss/yaml"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "0ca9ea5df5451ffdf184b4428c902747c2c11cd7"
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:850c49ca338a10fec2cb9e78f793043ed23965489d09e30bcc19fe29719da313"
|
||||
name = "github.com/go-sql-driver/mysql"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "a0583e0143b1624142adab07e0e97fe106d99561"
|
||||
version = "v1.3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:9ae31ce33b4bab257668963e844d98765b44160be4ee98cafc44637a213e530d"
|
||||
name = "github.com/gobwas/glob"
|
||||
packages = [
|
||||
".",
|
||||
@ -180,131 +221,168 @@
|
||||
"syntax/ast",
|
||||
"syntax/lexer",
|
||||
"util/runes",
|
||||
"util/strings"
|
||||
"util/strings",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "5ccd90ef52e1e632236f7326478d4faa74f99438"
|
||||
version = "v0.2.3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:615643b442214e7a9bade98fa7d50ec072fd17bdc5c955daa194b32e73a532a8"
|
||||
name = "github.com/gocraft/work"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "1d4117a214abff263b472043871c8666aedb716b"
|
||||
version = "v0.5.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:39d9284259004077d3b89109d592fce5f311788745ce94a7ccd4545e536ad3ac"
|
||||
name = "github.com/golang-migrate/migrate"
|
||||
packages = [
|
||||
".",
|
||||
"database",
|
||||
"database/postgres",
|
||||
"source",
|
||||
"source/file"
|
||||
"source/file",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "bcd996f3df28363f43e2d0935484c4559537a3eb"
|
||||
version = "v3.3.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:41e5cefde26c58f1560df2d1c32c2fa85e332d7cb4460d2077ae8fd8e0f3d789"
|
||||
name = "github.com/golang/protobuf"
|
||||
packages = [
|
||||
"proto",
|
||||
"ptypes/any",
|
||||
"ptypes/timestamp"
|
||||
"ptypes/timestamp",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "130e6b02ab059e7b717a096f397c5b60111cae74"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:38ec74012390146c45af1f92d46e5382b50531247929ff3a685d2b2be65155ac"
|
||||
name = "github.com/gomodule/redigo"
|
||||
packages = [
|
||||
"internal",
|
||||
"redis"
|
||||
"redis",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "9c11da706d9b7902c6da69c592f75637793fe121"
|
||||
version = "v2.0.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:a63cff6b5d8b95638bfe300385d93b2a6d9d687734b863da8e09dc834510a690"
|
||||
name = "github.com/google/go-querystring"
|
||||
packages = ["query"]
|
||||
pruneopts = "UT"
|
||||
revision = "53e6ce116135b80d037921a7fdd5138cf32d7a8a"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:160eabf7a69910fd74f29c692718bc2437c1c1c7d4c9dea9712357752a70e5df"
|
||||
name = "github.com/gorilla/context"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a"
|
||||
version = "v1.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:185a43b59a1f4e7ad4e7ccafb8a1538193d897a2a75be16dda093ec42ad231cf"
|
||||
name = "github.com/gorilla/handlers"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "90663712d74cb411cbef281bc1e08c19d1a76145"
|
||||
version = "v1.3.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:3c44722a6360b8d8abf6f70f122c69007189be992a150e39571224c54a9bc380"
|
||||
name = "github.com/gorilla/mux"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "7f08801859139f86dfafd1c296e2cba9a80d292e"
|
||||
version = "v1.6.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:bd26bbaf1e9f9dfe829a88f87a0849b56f717c31785443a67668f2c752fa8412"
|
||||
name = "github.com/lib/pq"
|
||||
packages = [
|
||||
".",
|
||||
"oid"
|
||||
"oid",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "b2004221932bd6b13167ef654c81cffac36f7537"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ee0845ea64262e3d1a6e2eab768fcb2008a0c8e571b7a3bebea554a1c031aeeb"
|
||||
name = "github.com/mattn/go-sqlite3"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "6c771bb9887719704b210e87e934f08be014bdb1"
|
||||
version = "v1.6.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:5113b1edf6e2f370f9ce6101e7b5a86c3e8decd108067e34b762ae91e42964ee"
|
||||
name = "github.com/miekg/pkcs11"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "7283ca79f35edb89bc1b4ecae7f86a3680ce737f"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:159d8a990f45d4891f1f04cb6ad7eb18b307cd02d783f7d37fa7a3b93912b172"
|
||||
name = "github.com/opencontainers/go-digest"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "aa2ec055abd10d26d539eb630a92241b781ce4bc"
|
||||
version = "v1.0.0-rc0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:40e195917a951a8bf867cd05de2a46aaf1806c50cf92eebf4c16f78cd196f747"
|
||||
name = "github.com/pkg/errors"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
|
||||
version = "v0.8.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe"
|
||||
name = "github.com/pmezard/go-difflib"
|
||||
packages = ["difflib"]
|
||||
pruneopts = "UT"
|
||||
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:3f68283c56d93b885f33c679708079e834815138649e9f59ffbc572c2993e0f8"
|
||||
name = "github.com/robfig/cron"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "b024fc5ea0e34bc3f83d9941c8d60b0622bfaca4"
|
||||
version = "v1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:9424f440bba8f7508b69414634aef3b2b3a877e522d8a4624692412805407bb7"
|
||||
name = "github.com/spf13/pflag"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "583c0c0531f06d5278b7d917446061adc344b5cd"
|
||||
version = "v1.0.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:994df93785d966f82180e17a0857fa53f7155cddca3898ad00b27e8d4481e4ae"
|
||||
name = "github.com/stretchr/testify"
|
||||
packages = [
|
||||
"assert",
|
||||
"require"
|
||||
"require",
|
||||
"suite",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "b91bfb9ebec76498946beb6af7c0230c7cc7ba6c"
|
||||
version = "v1.2.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:9c94d918a2ac65f60d6b7895b2e9612e4554b40ee2446f2f807cadb3e57da7e2"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = [
|
||||
"cast5",
|
||||
@ -316,34 +394,42 @@
|
||||
"openpgp/packet",
|
||||
"openpgp/s2k",
|
||||
"pbkdf2",
|
||||
"ssh/terminal"
|
||||
"ssh/terminal",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "5f961cd492ac9d43fc33a8ef646bae79d113fd97"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:3373df9a79dbfdec0111498a2358444eee9f70c3748ee0e0c2a1ad993978f676"
|
||||
name = "golang.org/x/net"
|
||||
packages = [
|
||||
"context",
|
||||
"context/ctxhttp"
|
||||
"context/ctxhttp",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "075e191f18186a8ff2becaf64478e30f4545cdad"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:3d57c230f6800023b6fec274f38a139337b5fc0d00169a100a538eb3ef5e3da8"
|
||||
name = "golang.org/x/oauth2"
|
||||
packages = [
|
||||
".",
|
||||
"clientcredentials",
|
||||
"internal"
|
||||
"internal",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "bb50c06baba3d0c76f9d125c0719093e315b5b44"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:f21f21efdd315b95a015ffd7ddca70ca60ff021848618b5a4efd88bb1603335f"
|
||||
name = "golang.org/x/sys"
|
||||
packages = ["unix"]
|
||||
pruneopts = "UT"
|
||||
revision = "571f7bbbe08da2a8955aed9d4db316e78630e9a3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:52133d6859535332391e6193c8878d06347f28881111efa900392802485e9a18"
|
||||
name = "google.golang.org/appengine"
|
||||
packages = [
|
||||
"internal",
|
||||
@ -352,41 +438,53 @@
|
||||
"internal/log",
|
||||
"internal/remote_api",
|
||||
"internal/urlfetch",
|
||||
"urlfetch"
|
||||
"urlfetch",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "24e4144ec923c2374f6b06610c0df16a9222c3d9"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:79decf236a2000df456fe7478fd23da8af950563c922747b299e1fab7fa7d78f"
|
||||
name = "gopkg.in/asn1-ber.v1"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "4e86f4367175e39f69d9358a5f17b4dda270378d"
|
||||
version = "v1.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:79691acfc86fc3204928daf67e44955e8021ec5e10091599d344b0e16de32236"
|
||||
name = "gopkg.in/ldap.v2"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "8168ee085ee43257585e50c6441aadf54ecb2c9f"
|
||||
version = "v2.5.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:2a81c6e126d36ad027328cffaa4888fc3be40f09dc48028d1f93705b718130b9"
|
||||
name = "gopkg.in/yaml.v2"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "7f97868eec74b32b0982dd158a51a446d1da7eb5"
|
||||
version = "v2.1.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:8dce42a5fac31cbfdc756bd244389280a905a5364b21dd44cdcb044ee622bf8b"
|
||||
name = "k8s.io/apimachinery"
|
||||
packages = ["pkg/version"]
|
||||
pruneopts = "UT"
|
||||
revision = "f534d624797b270e5e46104dc7e2c2d61edbb85d"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:bf83d8940d59a175dad5ba323b47c6e62b3ba2dc9b2d449f629288deeeeb6582"
|
||||
name = "k8s.io/client-go"
|
||||
packages = ["util/homedir"]
|
||||
pruneopts = "UT"
|
||||
revision = "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65"
|
||||
version = "v8.0.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:1076dbb6a69b965ccfda2a06a04e5038db78eff586f74b5daf4a41444e6f6077"
|
||||
name = "k8s.io/helm"
|
||||
packages = [
|
||||
"cmd/helm/search",
|
||||
@ -403,14 +501,73 @@
|
||||
"pkg/sympath",
|
||||
"pkg/tlsutil",
|
||||
"pkg/urlutil",
|
||||
"pkg/version"
|
||||
"pkg/version",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "20adb27c7c5868466912eebdf6664e7390ebe710"
|
||||
version = "v2.9.1"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "862941e7de65d953c0133ea4b290a079990f38c7cd6e2f1139ac78706d0912b3"
|
||||
input-imports = [
|
||||
"github.com/Masterminds/semver",
|
||||
"github.com/astaxie/beego",
|
||||
"github.com/astaxie/beego/cache",
|
||||
"github.com/astaxie/beego/cache/redis",
|
||||
"github.com/astaxie/beego/context",
|
||||
"github.com/astaxie/beego/orm",
|
||||
"github.com/astaxie/beego/session",
|
||||
"github.com/astaxie/beego/session/redis",
|
||||
"github.com/astaxie/beego/validation",
|
||||
"github.com/beego/i18n",
|
||||
"github.com/casbin/casbin",
|
||||
"github.com/casbin/casbin/model",
|
||||
"github.com/casbin/casbin/persist",
|
||||
"github.com/casbin/casbin/util",
|
||||
"github.com/dghubble/sling",
|
||||
"github.com/dgrijalva/jwt-go",
|
||||
"github.com/docker/distribution",
|
||||
"github.com/docker/distribution/digest",
|
||||
"github.com/docker/distribution/health",
|
||||
"github.com/docker/distribution/manifest/schema1",
|
||||
"github.com/docker/distribution/manifest/schema2",
|
||||
"github.com/docker/distribution/reference",
|
||||
"github.com/docker/distribution/registry/auth/token",
|
||||
"github.com/docker/distribution/registry/client/auth/challenge",
|
||||
"github.com/docker/distribution/uuid",
|
||||
"github.com/docker/libtrust",
|
||||
"github.com/docker/notary",
|
||||
"github.com/docker/notary/client",
|
||||
"github.com/docker/notary/trustpinning",
|
||||
"github.com/docker/notary/tuf/data",
|
||||
"github.com/garyburd/redigo/redis",
|
||||
"github.com/ghodss/yaml",
|
||||
"github.com/go-sql-driver/mysql",
|
||||
"github.com/gocraft/work",
|
||||
"github.com/golang-migrate/migrate",
|
||||
"github.com/golang-migrate/migrate/database/postgres",
|
||||
"github.com/golang-migrate/migrate/source/file",
|
||||
"github.com/gomodule/redigo/redis",
|
||||
"github.com/gorilla/handlers",
|
||||
"github.com/gorilla/mux",
|
||||
"github.com/lib/pq",
|
||||
"github.com/mattn/go-sqlite3",
|
||||
"github.com/opencontainers/go-digest",
|
||||
"github.com/pkg/errors",
|
||||
"github.com/robfig/cron",
|
||||
"github.com/stretchr/testify/assert",
|
||||
"github.com/stretchr/testify/require",
|
||||
"github.com/stretchr/testify/suite",
|
||||
"golang.org/x/crypto/pbkdf2",
|
||||
"golang.org/x/oauth2",
|
||||
"golang.org/x/oauth2/clientcredentials",
|
||||
"gopkg.in/ldap.v2",
|
||||
"gopkg.in/yaml.v2",
|
||||
"k8s.io/helm/cmd/helm/search",
|
||||
"k8s.io/helm/pkg/chartutil",
|
||||
"k8s.io/helm/pkg/proto/hapi/chart",
|
||||
"k8s.io/helm/pkg/repo",
|
||||
]
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
@ -85,8 +85,7 @@ func (c *CfgManager) loadDefault() {
|
||||
// Init Default Value
|
||||
itemArray := metadata.Instance().GetAll()
|
||||
for _, item := range itemArray {
|
||||
// Every string type have default value, other types should have a default value
|
||||
if _, ok := item.ItemType.(*metadata.StringType); ok || len(item.DefaultValue) > 0 {
|
||||
if len(item.DefaultValue) > 0 {
|
||||
cfgValue, err := metadata.NewCfgValue(item.Name, item.DefaultValue)
|
||||
if err != nil {
|
||||
log.Errorf("loadDefault failed, config item, key: %v, err: %v", item.Name, err)
|
||||
@ -148,10 +147,17 @@ func (c *CfgManager) GetUserCfgs() map[string]interface{} {
|
||||
if item.Scope == metadata.UserScope {
|
||||
cfgValue, err := c.store.GetAnyType(item.Name)
|
||||
if err != nil {
|
||||
if err != metadata.ErrValueNotSet {
|
||||
if err == metadata.ErrValueNotSet {
|
||||
if _, ok := item.ItemType.(*metadata.StringType); ok {
|
||||
cfgValue = ""
|
||||
}
|
||||
if _, ok := item.ItemType.(*metadata.NonEmptyStringType); ok {
|
||||
cfgValue = ""
|
||||
}
|
||||
} else {
|
||||
log.Errorf("Failed to get value of key %v, error %v", item.Name, err)
|
||||
continue
|
||||
}
|
||||
continue
|
||||
}
|
||||
resultMap[item.Name] = cfgValue
|
||||
}
|
||||
|
@ -2,10 +2,11 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var TestDBConfig = map[string]interface{}{
|
||||
@ -36,6 +37,12 @@ func TestLoadFromDatabase(t *testing.T) {
|
||||
assert.Equal(t, `{"parameter":{"daily_time":0},"type":"daily"}`, configManager.Get("scan_all_policy").GetString())
|
||||
}
|
||||
|
||||
func TestLoadUserCfg(t *testing.T) {
|
||||
configMap := configManager.GetUserCfgs()
|
||||
assert.NotNil(t, configMap["ldap_url"])
|
||||
assert.NotNil(t, configMap["ldap_base_dn"])
|
||||
}
|
||||
|
||||
func TestSaveToDatabase(t *testing.T) {
|
||||
fmt.Printf("database config %#v\n", configManager.GetDatabaseCfg())
|
||||
configManager.Load()
|
||||
|
@ -29,7 +29,7 @@ type Robot struct {
|
||||
Name string `orm:"column(name)" json:"name"`
|
||||
Description string `orm:"column(description)" json:"description"`
|
||||
ProjectID int64 `orm:"column(project_id)" json:"project_id"`
|
||||
ExpiresAt int64 `orm:"column(expiresat)" json:"expiresat"`
|
||||
ExpiresAt int64 `orm:"column(expiresat)" json:"expires_at"`
|
||||
Disabled bool `orm:"column(disabled)" json:"disabled"`
|
||||
CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"`
|
||||
UpdateTime time.Time `orm:"column(update_time);auto_now" json:"update_time"`
|
||||
|
@ -93,6 +93,7 @@ type GeneralInfo struct {
|
||||
WithAdmiral bool `json:"with_admiral"`
|
||||
AdmiralEndpoint string `json:"admiral_endpoint"`
|
||||
AuthMode string `json:"auth_mode"`
|
||||
AuthProxySettings *models.HTTPAuthProxy `json:"authproxy_settings,omitempty"`
|
||||
RegistryURL string `json:"registry_url"`
|
||||
ProjectCreationRestrict string `json:"project_creation_restriction"`
|
||||
SelfRegistration bool `json:"self_registration"`
|
||||
@ -186,6 +187,13 @@ func (sia *SystemInfoAPI) GetGeneralInfo() {
|
||||
if info.WithClair {
|
||||
info.ClairVulnStatus = getClairVulnStatus()
|
||||
}
|
||||
if info.AuthMode == common.HTTPAuth {
|
||||
if s, err := config.HTTPAuthProxySetting(); err == nil {
|
||||
info.AuthProxySettings = s
|
||||
} else {
|
||||
log.Warningf("Failed to get auth proxy setting, error: %v", err)
|
||||
}
|
||||
}
|
||||
sia.Data["json"] = info
|
||||
sia.ServeJSON()
|
||||
}
|
||||
|
@ -394,11 +394,11 @@ export class MyAccessLogService extends AccessLogService {
|
||||
*
|
||||
* @param {(number | string)} projectId
|
||||
* @param {RequestQueryParams} [queryParams]
|
||||
* @returns {(Observable<AccessLog[]> | Promise<AccessLog[]> | AccessLog[])}
|
||||
* @returns {(Observable<AccessLog[]>)}
|
||||
*
|
||||
* @memberOf AccessLogService
|
||||
*/
|
||||
getAuditLogs(projectId: number | string, queryParams?: RequestQueryParams): Observable<AccessLog[]> | Promise<AccessLog[]> | AccessLog[]{
|
||||
getAuditLogs(projectId: number | string, queryParams?: RequestQueryParams): Observable<AccessLog[]> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -406,11 +406,11 @@ export class MyAccessLogService extends AccessLogService {
|
||||
* Get the recent logs.
|
||||
*
|
||||
* @param {number} lines : Specify how many lines should be returned.
|
||||
* @returns {(Observable<AccessLog[]> | Promise<AccessLog[]> | AccessLog[])}
|
||||
* @returns {(Observable<AccessLog[]>)}
|
||||
*
|
||||
* @memberOf AccessLogService
|
||||
*/
|
||||
getRecentLogs(lines: number): Observable<AccessLog[]> | Promise<AccessLog[]> | AccessLog[]{
|
||||
getRecentLogs(lines: number): Observable<AccessLog[]>{
|
||||
...
|
||||
}
|
||||
}
|
||||
@ -437,7 +437,7 @@ export class MyEndpointService extends EndpointService {
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
getEndpoints(endpointName?: string, queryParams?: RequestQueryParams): Observable<Endpoint[]> | Promise<Endpoint[]> | Endpoint[] {
|
||||
getEndpoints(endpointName?: string, queryParams?: RequestQueryParams): Observable<Endpoint[]> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -449,7 +449,7 @@ export class MyEndpointService extends EndpointService {
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
getEndpoint(endpointId: number | string): Observable<Endpoint> | Promise<Endpoint> | Endpoint {
|
||||
getEndpoint(endpointId: number | string): Observable<Endpoint>{
|
||||
...
|
||||
}
|
||||
|
||||
@ -461,7 +461,7 @@ export class MyEndpointService extends EndpointService {
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
createEndpoint(endpoint: Endpoint): Observable<any> | Promise<any> | any {
|
||||
createEndpoint(endpoint: Endpoint): Observable<any> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -474,7 +474,7 @@ export class MyEndpointService extends EndpointService {
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
updateEndpoint(endpointId: number | string, endpoint: Endpoint): Observable<any> | Promise<any> | any {
|
||||
updateEndpoint(endpointId: number | string, endpoint: Endpoint): Observable<any> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -486,7 +486,7 @@ export class MyEndpointService extends EndpointService {
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
deleteEndpoint(endpointId: number | string): Observable<any> | Promise<any> | any {
|
||||
deleteEndpoint(endpointId: number | string): Observable<any> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -498,7 +498,7 @@ export class MyEndpointService extends EndpointService {
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
pingEndpoint(endpoint: Endpoint): Observable<any> | Promise<any> | any {
|
||||
pingEndpoint(endpoint: Endpoint): Observable<any> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -508,7 +508,7 @@ export class MyEndpointService extends EndpointService {
|
||||
* @param {{number | string}} endpointId
|
||||
* @returns {{Observable<any> | any}}
|
||||
*/
|
||||
getEndpointWithReplicationRules(endpointId: number | string): Observable<any> | Promise<any> | any {
|
||||
getEndpointWithReplicationRules(endpointId: number | string): Observable<any> {
|
||||
...
|
||||
}
|
||||
}
|
||||
@ -534,11 +534,11 @@ export class MyReplicationService extends ReplicationService {
|
||||
* @param {(number | string)} [projectId]
|
||||
* @param {string} [ruleName]
|
||||
* @param {RequestQueryParams} [queryParams]
|
||||
* @returns {(Observable<ReplicationRule[]> | Promise<ReplicationRule[]> | ReplicationRule[])}
|
||||
* @returns {(Observable<ReplicationRule[]>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
getReplicationRules(projectId?: number | string, ruleName?: string, queryParams?: RequestQueryParams): Observable<ReplicationRule[]> | Promise<ReplicationRule[]> | ReplicationRule[] {
|
||||
getReplicationRules(projectId?: number | string, ruleName?: string, queryParams?: RequestQueryParams): Observable<ReplicationRule[]> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -546,11 +546,11 @@ export class MyReplicationService extends ReplicationService {
|
||||
* Get the specified replication rule.
|
||||
*
|
||||
* @param {(number | string)} ruleId
|
||||
* @returns {(Observable<ReplicationRule> | Promise<ReplicationRule> | ReplicationRule)}
|
||||
* @returns {(Observable<ReplicationRule>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
getReplicationRule(ruleId: number | string): Observable<ReplicationRule> | Promise<ReplicationRule> | ReplicationRule {
|
||||
getReplicationRule(ruleId: number | string): Observable<ReplicationRule> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -558,11 +558,11 @@ export class MyReplicationService extends ReplicationService {
|
||||
* Create new replication rule.
|
||||
*
|
||||
* @param {ReplicationRule} replicationRule
|
||||
* @returns {(Observable<any> | Promise<any> | any)}
|
||||
* @returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
createReplicationRule(replicationRule: ReplicationRule): Observable<any> | Promise<any> | any {
|
||||
createReplicationRule(replicationRule: ReplicationRule): Observable<any> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -570,11 +570,11 @@ export class MyReplicationService extends ReplicationService {
|
||||
* Update the specified replication rule.
|
||||
*
|
||||
* @param {ReplicationRule} replicationRule
|
||||
* @returns {(Observable<any> | Promise<any> | any)}
|
||||
* @returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
updateReplicationRule(replicationRule: ReplicationRule): Observable<any> | Promise<any> | any {
|
||||
updateReplicationRule(replicationRule: ReplicationRule): Observable<any> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -582,11 +582,11 @@ export class MyReplicationService extends ReplicationService {
|
||||
* Delete the specified replication rule.
|
||||
*
|
||||
* @param {(number | string)} ruleId
|
||||
* @returns {(Observable<any> | Promise<any> | any)}
|
||||
* @returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
deleteReplicationRule(ruleId: number | string): Observable<any> | Promise<any> | any {
|
||||
deleteReplicationRule(ruleId: number | string): Observable<any> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -594,11 +594,11 @@ export class MyReplicationService extends ReplicationService {
|
||||
* Enable the specified replication rule.
|
||||
*
|
||||
* @param {(number | string)} ruleId
|
||||
* @returns {(Observable<any> | Promise<any> | any)}
|
||||
* @returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
enableReplicationRule(ruleId: number | string, enablement: number): Observable<any> | Promise<any> | any {
|
||||
enableReplicationRule(ruleId: number | string, enablement: number): Observable<any> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -606,11 +606,11 @@ export class MyReplicationService extends ReplicationService {
|
||||
* Disable the specified replication rule.
|
||||
*
|
||||
* @param {(number | string)} ruleId
|
||||
* @returns {(Observable<any> | Promise<any> | any)}
|
||||
* @returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
disableReplicationRule(ruleId: number | string): Observable<any> | Promise<any> | any {
|
||||
disableReplicationRule(ruleId: number | string): Observable<any> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -625,11 +625,11 @@ export class MyReplicationService extends ReplicationService {
|
||||
*
|
||||
* @param {(number | string)} ruleId
|
||||
* @param {RequestQueryParams} [queryParams]
|
||||
* @returns {(Observable<ReplicationJob> | Promise<ReplicationJob[]> | ReplicationJob)}
|
||||
* @returns {(Observable<ReplicationJob>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
getJobs(ruleId: number | string, queryParams?: RequestQueryParams): Observable<ReplicationJob[]> | Promise<ReplicationJob[]> | ReplicationJob[] {
|
||||
getJobs(ruleId: number | string, queryParams?: RequestQueryParams): Observable<ReplicationJob[]> {
|
||||
...
|
||||
}
|
||||
}
|
||||
@ -656,11 +656,11 @@ export class MyRepositoryService extends RepositoryService {
|
||||
* @param {(number | string)} projectId
|
||||
* @param {string} repositoryName
|
||||
* @param {RequestQueryParams} [queryParams]
|
||||
* @returns {(Observable<Repository[]> | Promise<Repository[]> | Repository[])}
|
||||
* @returns {(Observable<Repository[]>)}
|
||||
*
|
||||
* @memberOf RepositoryService
|
||||
*/
|
||||
getRepositories(projectId: number | string, repositoryName?: string, queryParams?: RequestQueryParams): Observable<Repository[]> | Promise<Repository[]> | Repository[] {
|
||||
getRepositories(projectId: number | string, repositoryName?: string, queryParams?: RequestQueryParams): Observable<Repository[]> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -668,11 +668,11 @@ export class MyRepositoryService extends RepositoryService {
|
||||
* DELETE the specified repository.
|
||||
*
|
||||
* @param {string} repositoryName
|
||||
* @returns {(Observable<any> | Promise<any> | any)}
|
||||
* @returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf RepositoryService
|
||||
*/
|
||||
deleteRepository(repositoryName: string): Observable<any> | Promise<any> | any {
|
||||
deleteRepository(repositoryName: string): Observable<any> {
|
||||
...
|
||||
}
|
||||
}
|
||||
@ -694,11 +694,11 @@ export class MyTagService extends TagService {
|
||||
*
|
||||
* @param {string} repositoryName
|
||||
* @param {RequestQueryParams} [queryParams]
|
||||
* @returns {(Observable<Tag[]> | Promise<Tag[]> | Tag[])}
|
||||
* @returns {(Observable<Tag[]>)}
|
||||
*
|
||||
* @memberOf TagService
|
||||
*/
|
||||
getTags(repositoryName: string, queryParams?: RequestQueryParams): Observable<Tag[]> | Promise<Tag[]> | Tag[] {
|
||||
getTags(repositoryName: string, queryParams?: RequestQueryParams): Observable<Tag[]> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -711,7 +711,7 @@ export class MyTagService extends TagService {
|
||||
*
|
||||
* @memberOf TagService
|
||||
*/
|
||||
deleteTag(repositoryName: string, tag: string): Observable<any> | Promise<Tag> | any {
|
||||
deleteTag(repositoryName: string, tag: string): Observable<any> {
|
||||
...
|
||||
}
|
||||
}
|
||||
@ -738,11 +738,11 @@ export class MyScanningResultService extends ScanningResultService {
|
||||
* Get the summary of vulnerability scanning result.
|
||||
*
|
||||
* @param {string} tagId
|
||||
* @returns {(Observable<VulnerabilitySummary> | Promise<VulnerabilitySummary> | VulnerabilitySummary)}
|
||||
* @returns {(Observable<VulnerabilitySummary>)}
|
||||
*
|
||||
* @memberOf ScanningResultService
|
||||
*/
|
||||
getVulnerabilityScanningSummary(repoName: string, tagId: string, queryParams?: RequestQueryParams): Observable<VulnerabilitySummary> | Promise<VulnerabilitySummary> | VulnerabilitySummary{
|
||||
getVulnerabilityScanningSummary(repoName: string, tagId: string, queryParams?: RequestQueryParams): Observable<VulnerabilitySummary> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -750,11 +750,11 @@ export class MyScanningResultService extends ScanningResultService {
|
||||
* Get the detailed vulnerabilities scanning results.
|
||||
*
|
||||
* @param {string} tagId
|
||||
* @returns {(Observable<VulnerabilityItem[]> | Promise<VulnerabilityItem[]> | VulnerabilityItem[])}
|
||||
* @returns {(Observable<VulnerabilityItem[]>)}
|
||||
*
|
||||
* @memberOf ScanningResultService
|
||||
*/
|
||||
getVulnerabilityScanningResults(repoName: string, tagId: string, queryParams?: RequestQueryParams): Observable<VulnerabilityItem[]> | Promise<VulnerabilityItem[]> | VulnerabilityItem[]{
|
||||
getVulnerabilityScanningResults(repoName: string, tagId: string, queryParams?: RequestQueryParams): Observable<VulnerabilityItem[]> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -764,11 +764,11 @@ export class MyScanningResultService extends ScanningResultService {
|
||||
*
|
||||
* @param {string} repoName
|
||||
* @param {string} tagId
|
||||
* @returns {(Observable<any> | Promise<any> | any)}
|
||||
* @returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ScanningResultService
|
||||
*/
|
||||
startVulnerabilityScanning(repoName: string, tagId: string): Observable<any> | Promise<any> | any {
|
||||
startVulnerabilityScanning(repoName: string, tagId: string): Observable<any> {
|
||||
...
|
||||
}
|
||||
}
|
||||
@ -792,7 +792,7 @@ export class MySystemInfoService extends SystemInfoService {
|
||||
* Get global system information.
|
||||
* @returns
|
||||
*/
|
||||
getSystemInfo(): Observable<SystemInfo> | Promise<SystemInfo> | SystemInfo {
|
||||
getSystemInfo(): Observable<SystemInfo> {
|
||||
...
|
||||
}
|
||||
}
|
||||
@ -820,11 +820,11 @@ export class MyConfigurationService extends ConfigurationService{
|
||||
* Get configurations.
|
||||
*
|
||||
|
||||
* @returns {(Observable<Configuration> | Promise<Configuration> | Configuration)}
|
||||
* @returns {(Observable<Configuration>)}
|
||||
*
|
||||
* @memberOf ConfigurationService
|
||||
*/
|
||||
getConfigurations(): Observable<Configuration> | Promise<Configuration> | Configuration{
|
||||
getConfigurations(): Observable<Configuration> {
|
||||
...
|
||||
}
|
||||
|
||||
@ -832,11 +832,11 @@ export class MyConfigurationService extends ConfigurationService{
|
||||
* Save configurations.
|
||||
*
|
||||
|
||||
* @returns {(Observable<Configuration> | Promise<Configuration> | Configuration)}
|
||||
* @returns {(Observable<Configuration>)}
|
||||
*
|
||||
* @memberOf ConfigurationService
|
||||
*/
|
||||
saveConfigurations(changedConfigs: any | { [key: string]: any | any[] }): Observable<any> | Promise<any> | any{
|
||||
saveConfigurations(changedConfigs: any | { [key: string]: any | any[] }): Observable<any> {
|
||||
...
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ export class Configuration {
|
||||
ldap_group_search_filter: StringValueItem;
|
||||
ldap_group_attribute_name: StringValueItem;
|
||||
ldap_group_search_scope: NumberValueItem;
|
||||
ldap_group_membership_attribute: StringValueItem;
|
||||
uaa_client_id: StringValueItem;
|
||||
uaa_client_secret?: StringValueItem;
|
||||
uaa_endpoint: StringValueItem;
|
||||
@ -108,6 +109,7 @@ export class Configuration {
|
||||
this.ldap_group_search_filter = new StringValueItem("", true);
|
||||
this.ldap_group_attribute_name = new StringValueItem("", true);
|
||||
this.ldap_group_search_scope = new NumberValueItem(0, true);
|
||||
this.ldap_group_membership_attribute = new StringValueItem("", true);
|
||||
this.uaa_client_id = new StringValueItem("", true);
|
||||
this.uaa_client_secret = new StringValueItem("", true);
|
||||
this.uaa_endpoint = new StringValueItem("", true);
|
||||
|
@ -1,5 +1,5 @@
|
||||
<div class="cron-selection">
|
||||
<cron-selection [labelCurrent]="getLabelCurrent" [labelEdit]='getText' [originCron]='originCron' (inputvalue)="getcron($event)"></cron-selection>
|
||||
<cron-selection [labelCurrent]="getLabelCurrent" [labelEdit]='getText' [originCron]='originCron' (inputvalue)="scheduleGc($event)"></cron-selection>
|
||||
</div>
|
||||
<button class="btn btn-primary btn-sm gc-start-btn" (click)="gcNow()" [disabled]="disableGC">{{'GC.GC_NOW' | translate}}</button>
|
||||
<div class="job-header font-style">{{'GC.JOB_HISTORY' | translate}}</div>
|
||||
|
@ -97,7 +97,17 @@ export class GcComponent implements OnInit {
|
||||
this.disableGC = false;
|
||||
}
|
||||
|
||||
getcron(cron: string) {
|
||||
private resetSchedule(cron) {
|
||||
this.schedule = {
|
||||
schedule: {
|
||||
type: this.CronScheduleComponent.scheduleType,
|
||||
cron: cron
|
||||
}
|
||||
};
|
||||
this.getJobs();
|
||||
}
|
||||
|
||||
scheduleGc(cron: string) {
|
||||
let schedule = this.schedule;
|
||||
if (schedule && schedule.schedule && schedule.schedule.type !== SCHEDULE_TYPE_NONE) {
|
||||
this.gcRepoService.putScheduleGc(this.CronScheduleComponent.scheduleType, cron).subscribe(
|
||||
@ -107,7 +117,7 @@ export class GcComponent implements OnInit {
|
||||
.subscribe((res) => {
|
||||
this.errorHandler.info(res);
|
||||
});
|
||||
this.getJobs();
|
||||
this.resetSchedule(cron);
|
||||
},
|
||||
error => {
|
||||
this.errorHandler.error(error);
|
||||
@ -119,7 +129,7 @@ export class GcComponent implements OnInit {
|
||||
this.translate.get("GC.MSG_SCHEDULE_SET").subscribe((res) => {
|
||||
this.errorHandler.info(res);
|
||||
});
|
||||
this.getJobs();
|
||||
this.resetSchedule(cron);
|
||||
},
|
||||
error => {
|
||||
this.errorHandler.error(error);
|
||||
|
@ -21,6 +21,7 @@ import {
|
||||
SystemInfo
|
||||
} from '../service/index';
|
||||
import { Configuration } from './config';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('RegistryConfigComponent (inline template)', () => {
|
||||
|
||||
@ -84,8 +85,8 @@ describe('RegistryConfigComponent (inline template)', () => {
|
||||
|
||||
cfgService = fixture.debugElement.injector.get(ConfigurationService);
|
||||
systemInfoService = fixture.debugElement.injector.get(SystemInfoService);
|
||||
spy = spyOn(cfgService, 'getConfigurations').and.returnValue(Promise.resolve(mockConfig));
|
||||
spySystemInfo = spyOn(systemInfoService, 'getSystemInfo').and.returnValue(Promise.resolve(mockSystemInfo));
|
||||
spy = spyOn(cfgService, 'getConfigurations').and.returnValue(of(mockConfig));
|
||||
spySystemInfo = spyOn(systemInfoService, 'getSystemInfo').and.returnValue(of(mockSystemInfo));
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
@ -100,7 +101,7 @@ describe('RegistryConfigComponent (inline template)', () => {
|
||||
|
||||
let el: HTMLInputElement = fixture.nativeElement.querySelector('input[type="text"]');
|
||||
expect(el).not.toBeFalsy();
|
||||
expect(el.value).toEqual('30');
|
||||
expect(el.value).toEqual('90');
|
||||
|
||||
|
||||
fixture.detectChanges();
|
||||
|
@ -7,7 +7,6 @@ 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,
|
||||
isEmptyObject,
|
||||
clone
|
||||
@ -15,6 +14,7 @@ import {
|
||||
import { ErrorHandler } from '../error-handler/index';
|
||||
import { SystemSettingsComponent, VulnerabilityConfigComponent, GcComponent} from './index';
|
||||
import { Configuration } from './config';
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
|
||||
@Component({
|
||||
selector: 'hbr-registry-config',
|
||||
@ -75,21 +75,21 @@ export class RegistryConfigComponent implements OnInit {
|
||||
|
||||
// Get system info
|
||||
loadSystemInfo(): void {
|
||||
toPromise<SystemInfo>(this.systemInfoService.getSystemInfo())
|
||||
.then((info: SystemInfo) => this.systemInfo = info)
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
this.systemInfoService.getSystemInfo()
|
||||
.subscribe((info: SystemInfo) => {
|
||||
this.systemInfo = info;
|
||||
}, error => this.errorHandler.error(error));
|
||||
}
|
||||
|
||||
// Load configurations
|
||||
load(): void {
|
||||
this.onGoing = true;
|
||||
toPromise<Configuration>(this.configService.getConfigurations())
|
||||
.then((config: Configuration) => {
|
||||
this.configService.getConfigurations()
|
||||
.subscribe((config: Configuration) => {
|
||||
this.configCopy = clone(config);
|
||||
this.config = config;
|
||||
this.onGoing = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
this.onGoing = false;
|
||||
});
|
||||
@ -105,8 +105,8 @@ export class RegistryConfigComponent implements OnInit {
|
||||
}
|
||||
|
||||
this.onGoing = true;
|
||||
toPromise<any>(this.configService.saveConfigurations(changes))
|
||||
.then(() => {
|
||||
this.configService.saveConfigurations(changes)
|
||||
.subscribe(() => {
|
||||
this.onGoing = false;
|
||||
|
||||
this.translate.get("CONFIG.SAVE_SUCCESS").subscribe((res: string) => {
|
||||
@ -116,8 +116,8 @@ export class RegistryConfigComponent implements OnInit {
|
||||
this.load();
|
||||
// Reload all system info
|
||||
// this.loadSystemInfo();
|
||||
})
|
||||
.catch(error => {
|
||||
}
|
||||
, error => {
|
||||
this.onGoing = false;
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
|
@ -2,7 +2,7 @@ import { Component, Input, OnInit, Output, EventEmitter, ViewChild, Inject, OnCh
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { Configuration, StringValueItem } from '../config';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../../service.config';
|
||||
import { clone, isEmpty, getChanges, toPromise } from '../../utils';
|
||||
import { clone, isEmpty, getChanges } from '../../utils';
|
||||
import { ErrorHandler } from '../../error-handler/index';
|
||||
import { ConfirmationMessage } from '../../confirmation-dialog/confirmation-message';
|
||||
import { ConfirmationDialogComponent } from '../../confirmation-dialog/confirmation-dialog.component';
|
||||
@ -115,7 +115,7 @@ export class SystemSettingsComponent implements OnChanges, OnInit {
|
||||
if (!isEmpty(changes)) {
|
||||
this.onGoing = true;
|
||||
this.configService.saveConfigurations(changes)
|
||||
.then(response => {
|
||||
.subscribe(response => {
|
||||
this.onGoing = false;
|
||||
// API should return the updated configurations here
|
||||
// Unfortunately API does not do that
|
||||
@ -129,8 +129,8 @@ export class SystemSettingsComponent implements OnChanges, OnInit {
|
||||
|
||||
this.reloadSystemConfig.emit();
|
||||
this.errorHandler.info('CONFIG.SAVE_SUCCESS');
|
||||
})
|
||||
.catch(error => {
|
||||
}
|
||||
, error => {
|
||||
this.onGoing = false;
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
@ -142,7 +142,7 @@ export class SystemSettingsComponent implements OnChanges, OnInit {
|
||||
|
||||
retrieveConfig(): void {
|
||||
this.onGoing = true;
|
||||
from(toPromise(this.configService.getConfigurations()))
|
||||
this.configService.getConfigurations()
|
||||
.subscribe((configurations: Configuration) => {
|
||||
this.onGoing = false;
|
||||
// Add two password fields
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Component, Input, Output, EventEmitter, ViewChild, OnInit } from '@angular/core';
|
||||
import { NgForm } from '@angular/forms';
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError, of } from "rxjs";
|
||||
import { Configuration } from '../config';
|
||||
import {
|
||||
ScanningResultService,
|
||||
@ -9,7 +10,7 @@ import {
|
||||
ConfigurationService
|
||||
} from '../../service/index';
|
||||
import { ErrorHandler } from '../../error-handler/index';
|
||||
import { toPromise, isEmptyObject, clone} from '../../utils';
|
||||
import { isEmptyObject, clone} from '../../utils';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { ClairDetail } from '../../service/interface';
|
||||
const ONE_HOUR_SECONDS: number = 3600;
|
||||
@ -241,12 +242,11 @@ export class VulnerabilityConfigComponent implements OnInit {
|
||||
}
|
||||
|
||||
getConfigurations(): void {
|
||||
toPromise<Configuration>(this.configService.getConfigurations())
|
||||
.then((config: Configuration) => {
|
||||
this.configService.getConfigurations()
|
||||
.subscribe((config: Configuration) => {
|
||||
this.configCopy = clone(config);
|
||||
this.config = config;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
}
|
||||
@ -272,20 +272,20 @@ export class VulnerabilityConfigComponent implements OnInit {
|
||||
}
|
||||
|
||||
this.onSubmitting = true;
|
||||
toPromise<any>(this.scanningService.startScanningAll())
|
||||
.then(() => {
|
||||
this.scanningService.startScanningAll()
|
||||
.subscribe(() => {
|
||||
this.translate.get("CONFIG.SCANNING.TRIGGER_SCAN_ALL_SUCCESS").subscribe((res: string) => {
|
||||
this.errorHandler.info(res);
|
||||
});
|
||||
|
||||
// Update system info
|
||||
this.getSystemInfo().then(() => {
|
||||
this.getSystemInfo().subscribe(() => {
|
||||
this.onSubmitting = false;
|
||||
}).catch(() => {
|
||||
}, error => {
|
||||
this.onSubmitting = false;
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
}
|
||||
, error => {
|
||||
if (error && error.status && error.status === 412) {
|
||||
this.translate.get("CONFIG.SCANNING.TRIGGER_SCAN_ALL_FAIL", { error: '' + error }).subscribe((res: string) => {
|
||||
this.errorHandler.error(res);
|
||||
@ -297,10 +297,13 @@ export class VulnerabilityConfigComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
getSystemInfo(): Promise<void | SystemInfo> {
|
||||
return toPromise<SystemInfo>(this.systemInfoService.getSystemInfo())
|
||||
.then((info: SystemInfo) => this.systemInfo = info)
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
getSystemInfo(): Observable<void | SystemInfo> {
|
||||
return this.systemInfoService.getSystemInfo()
|
||||
.pipe(map((info: SystemInfo) => this.systemInfo = info)
|
||||
, catchError(error => {
|
||||
this.errorHandler.error(error);
|
||||
return of();
|
||||
}));
|
||||
}
|
||||
|
||||
save(): void {
|
||||
@ -311,17 +314,14 @@ export class VulnerabilityConfigComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
|
||||
toPromise<any>(this.configService.saveConfigurations(changes))
|
||||
.then(() => {
|
||||
this.configService.saveConfigurations(changes)
|
||||
.subscribe(() => {
|
||||
this.translate.get("CONFIG.SAVE_SUCCESS").subscribe((res: string) => {
|
||||
this.errorHandler.info(res);
|
||||
});
|
||||
this.getConfigurations();
|
||||
this.isEditMode = false;
|
||||
}, () => {
|
||||
this.reset();
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
this.reset();
|
||||
});
|
||||
|
@ -18,6 +18,7 @@ import {
|
||||
EndpointDefaultService
|
||||
} from "../service/endpoint.service";
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../service.config";
|
||||
import { of } from "rxjs";
|
||||
describe("CreateEditEndpointComponent (inline template)", () => {
|
||||
let mockData: Endpoint = {
|
||||
id: 1,
|
||||
@ -80,7 +81,7 @@ describe("CreateEditEndpointComponent (inline template)", () => {
|
||||
);
|
||||
|
||||
spy = spyOn(endpointService, "getEndpoint").and.returnValue(
|
||||
Promise.resolve(mockData)
|
||||
of(mockData)
|
||||
);
|
||||
fixture.detectChanges();
|
||||
|
||||
|
@ -29,7 +29,8 @@ import { EndpointService } from "../service/endpoint.service";
|
||||
import { ErrorHandler } from "../error-handler/index";
|
||||
import { InlineAlertComponent } from "../inline-alert/inline-alert.component";
|
||||
import { Endpoint, Adapter } from "../service/interface";
|
||||
import { toPromise, clone, compareValue, isEmptyObject } from "../utils";
|
||||
import { clone, compareValue, isEmptyObject } from "../utils";
|
||||
|
||||
|
||||
|
||||
const FAKE_PASSWORD = "rjGcfuRu";
|
||||
@ -71,14 +72,14 @@ export class CreateEditEndpointComponent
|
||||
private errorHandler: ErrorHandler,
|
||||
private translateService: TranslateService,
|
||||
private ref: ChangeDetectorRef
|
||||
) {}
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
toPromise<Adapter[]>(this.endpointService.getAdapters())
|
||||
.then(adapters => {
|
||||
this.adapterList = adapters || [];
|
||||
})
|
||||
.catch((error: any) => this.errorHandler.error(error));
|
||||
this.endpointService.getAdapters().subscribe(adapters => {
|
||||
this.adapterList = adapters || [];
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
public get isValid(): boolean {
|
||||
@ -118,7 +119,7 @@ export class CreateEditEndpointComponent
|
||||
name: "",
|
||||
type: "Harbor",
|
||||
url: "",
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
open(): void {
|
||||
@ -166,8 +167,8 @@ export class CreateEditEndpointComponent
|
||||
this.translateService
|
||||
.get("DESTINATION.TITLE_EDIT")
|
||||
.subscribe(res => (this.modalTitle = res));
|
||||
toPromise<Endpoint>(this.endpointService.getEndpoint(targetId))
|
||||
.then(target => {
|
||||
this.endpointService.getEndpoint(targetId)
|
||||
.subscribe(target => {
|
||||
this.target = target;
|
||||
// Keep data cache
|
||||
this.initVal = clone(target);
|
||||
@ -178,8 +179,7 @@ export class CreateEditEndpointComponent
|
||||
this.open();
|
||||
this.controlEnabled = true;
|
||||
this.forceRefreshView(2000);
|
||||
})
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
}, error => this.errorHandler.error(error));
|
||||
} else {
|
||||
this.endpointId = "";
|
||||
this.translateService
|
||||
@ -213,15 +213,14 @@ export class CreateEditEndpointComponent
|
||||
}
|
||||
|
||||
this.testOngoing = true;
|
||||
toPromise<Endpoint>(this.endpointService.pingEndpoint(payload))
|
||||
.then(response => {
|
||||
this.endpointService.pingEndpoint(payload)
|
||||
.subscribe(response => {
|
||||
this.inlineAlert.showInlineSuccess({
|
||||
message: "DESTINATION.TEST_CONNECTION_SUCCESS"
|
||||
});
|
||||
this.forceRefreshView(2000);
|
||||
this.testOngoing = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.inlineAlert.showInlineError("DESTINATION.TEST_CONNECTION_FAILURE");
|
||||
this.forceRefreshView(2000);
|
||||
this.testOngoing = false;
|
||||
@ -241,8 +240,8 @@ export class CreateEditEndpointComponent
|
||||
return; // Avoid duplicated submitting
|
||||
}
|
||||
this.onGoing = true;
|
||||
toPromise<number>(this.endpointService.createEndpoint(this.target))
|
||||
.then(response => {
|
||||
this.endpointService.createEndpoint(this.target)
|
||||
.subscribe(response => {
|
||||
this.translateService
|
||||
.get("DESTINATION.CREATED_SUCCESS")
|
||||
.subscribe(res => this.errorHandler.info(res));
|
||||
@ -250,8 +249,7 @@ export class CreateEditEndpointComponent
|
||||
this.onGoing = false;
|
||||
this.close();
|
||||
this.forceRefreshView(2000);
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
let errorMessageKey = this.handleErrorMessageKey(error.status);
|
||||
this.translateService.get(errorMessageKey).subscribe(res => {
|
||||
@ -285,10 +283,8 @@ export class CreateEditEndpointComponent
|
||||
}
|
||||
|
||||
this.onGoing = true;
|
||||
toPromise<number>(
|
||||
this.endpointService.updateEndpoint(this.target.id, payload)
|
||||
)
|
||||
.then(response => {
|
||||
this.endpointService.updateEndpoint(this.target.id, payload)
|
||||
.subscribe(response => {
|
||||
this.translateService
|
||||
.get("DESTINATION.UPDATED_SUCCESS")
|
||||
.subscribe(res => this.errorHandler.info(res));
|
||||
@ -296,8 +292,7 @@ export class CreateEditEndpointComponent
|
||||
this.close();
|
||||
this.onGoing = false;
|
||||
this.forceRefreshView(2000);
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
let errorMessageKey = this.handleErrorMessageKey(error.status);
|
||||
this.translateService.get(errorMessageKey).subscribe(res => {
|
||||
this.inlineAlert.showInlineError(res);
|
||||
|
@ -9,6 +9,7 @@ import { Label } from "../service/interface";
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../service.config";
|
||||
import { CreateEditLabelComponent } from "./create-edit-label.component";
|
||||
import { LabelDefaultService, LabelService } from "../service/label.service";
|
||||
import { of } from "rxjs";
|
||||
|
||||
describe("CreateEditLabelComponent (inline template)", () => {
|
||||
let mockOneData: Label = {
|
||||
@ -57,10 +58,10 @@ describe("CreateEditLabelComponent (inline template)", () => {
|
||||
labelService = fixture.debugElement.injector.get(LabelService);
|
||||
|
||||
spy = spyOn(labelService, "getLabels").and.returnValue(
|
||||
Promise.resolve(mockOneData)
|
||||
of(mockOneData)
|
||||
);
|
||||
spyOne = spyOn(labelService, "createLabel").and.returnValue(
|
||||
Promise.resolve(mockOneData)
|
||||
of(mockOneData)
|
||||
);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
@ -25,7 +25,7 @@ import {
|
||||
|
||||
import { Label } from "../service/interface";
|
||||
|
||||
import { toPromise, clone, compareValue } from "../utils";
|
||||
import { clone, compareValue } from "../utils";
|
||||
|
||||
import { LabelService } from "../service/label.service";
|
||||
import { ErrorHandler } from "../error-handler/error-handler";
|
||||
@ -66,10 +66,8 @@ export class CreateEditLabelComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.nameChecker.pipe(debounceTime(500)).subscribe((name: string) => {
|
||||
toPromise<Label[]>(
|
||||
this.labelService.getLabels(this.scope, this.projectId, name)
|
||||
)
|
||||
.then(targets => {
|
||||
.subscribe(targets => {
|
||||
this.isLabelNameExist = false;
|
||||
if (targets && targets.length) {
|
||||
if (targets.find((target) => {
|
||||
@ -78,8 +76,7 @@ export class CreateEditLabelComponent implements OnInit, OnDestroy {
|
||||
this.isLabelNameExist = true;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
let hnd = setInterval(() => this.ref.markForCheck(), 100);
|
||||
@ -145,28 +142,24 @@ export class CreateEditLabelComponent implements OnInit, OnDestroy {
|
||||
if (this.labelId <= 0) {
|
||||
this.labelModel.scope = this.scope;
|
||||
this.labelModel.project_id = this.projectId;
|
||||
toPromise<Label>(this.labelService.createLabel(this.labelModel))
|
||||
.then(res => {
|
||||
this.labelService.createLabel(this.labelModel)
|
||||
.subscribe(res => {
|
||||
this.inProgress = false;
|
||||
this.reload.emit();
|
||||
this.labelModel = this.initLabel();
|
||||
this.formShow = false;
|
||||
})
|
||||
.catch(err => {
|
||||
}, err => {
|
||||
this.inProgress = false;
|
||||
this.errorHandler.error(err);
|
||||
});
|
||||
} else {
|
||||
toPromise<Label>(
|
||||
this.labelService.updateLabel(this.labelId, this.labelModel)
|
||||
)
|
||||
.then(res => {
|
||||
.subscribe(res => {
|
||||
this.inProgress = false;
|
||||
this.reload.emit();
|
||||
this.labelModel = this.initLabel();
|
||||
this.formShow = false;
|
||||
})
|
||||
.catch(err => {
|
||||
}, err => {
|
||||
this.inProgress = false;
|
||||
this.errorHandler.error(err);
|
||||
});
|
||||
|
@ -41,6 +41,7 @@ import {FilterLabelComponent} from "./filter-label.component";
|
||||
import {LabelService} from "../service/label.service";
|
||||
import {LabelPieceComponent} from "../label-piece/label-piece.component";
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { of } from "rxjs";
|
||||
|
||||
describe("CreateEditRuleComponent (inline template)", () => {
|
||||
let mockRules: ReplicationRule[] = [
|
||||
@ -221,17 +222,16 @@ describe("CreateEditRuleComponent (inline template)", () => {
|
||||
spyRules = spyOn(
|
||||
replicationService,
|
||||
"getReplicationRules"
|
||||
).and.returnValues(Promise.resolve(mockRules));
|
||||
).and.returnValues(of(mockRules));
|
||||
spyOneRule = spyOn(
|
||||
replicationService,
|
||||
"getReplicationRule"
|
||||
).and.returnValue(Promise.resolve(mockRule));
|
||||
).and.returnValue(of(mockRule));
|
||||
spyJobs = spyOn(replicationService, "getExecutions").and.returnValues(
|
||||
Promise.resolve(mockJob)
|
||||
);
|
||||
of(mockJob));
|
||||
|
||||
spyEndpoint = spyOn(endpointService, "getEndpoints").and.returnValues(
|
||||
Promise.resolve(mockEndpoints)
|
||||
of(mockEndpoints)
|
||||
);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
@ -22,10 +22,10 @@ import {
|
||||
Output
|
||||
} from "@angular/core";
|
||||
import { Filter, ReplicationRule, Endpoint, Label } from "../service/interface";
|
||||
import { Subject , Subscription } from "rxjs";
|
||||
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
|
||||
import { Subject, Subscription } from "rxjs";
|
||||
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
||||
import { FormArray, FormBuilder, FormGroup, Validators, FormControl } from "@angular/forms";
|
||||
import { clone, compareValue, isEmptyObject, toPromise } from "../utils";
|
||||
import { clone, compareValue, isEmptyObject } from "../utils";
|
||||
import { InlineAlertComponent } from "../inline-alert/inline-alert.component";
|
||||
import { ReplicationService } from "../service/replication.service";
|
||||
import { ErrorHandler } from "../error-handler/error-handler";
|
||||
@ -143,12 +143,14 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
||||
this.filterSelect = ["type", "repository", "tag"];
|
||||
}
|
||||
|
||||
toPromise<Endpoint[]>(this.endpointService.getEndpoints())
|
||||
.then(endPoints => {
|
||||
this.targetList = endPoints || [];
|
||||
this.sourceList = endPoints || [];
|
||||
})
|
||||
.catch((error: any) => this.errorHandler.error(error));
|
||||
|
||||
this.endpointService.getEndpoints().subscribe(endPoints => {
|
||||
this.targetList = endPoints || [];
|
||||
this.sourceList = endPoints || [];
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
|
||||
|
||||
this.nameChecker
|
||||
.pipe(debounceTime(300))
|
||||
@ -159,17 +161,14 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
||||
this.isRuleNameValid = cont.valid;
|
||||
if (this.isRuleNameValid) {
|
||||
this.inNameChecking = true;
|
||||
toPromise<ReplicationRule[]>(
|
||||
this.repService.getReplicationRules(0, ruleName)
|
||||
)
|
||||
.then(response => {
|
||||
this.repService.getReplicationRules(0, ruleName)
|
||||
.subscribe(response => {
|
||||
if (response.some(rule => rule.name === ruleName)) {
|
||||
this.ruleNameTooltip = "TOOLTIP.RULE_USER_EXISTING";
|
||||
this.isRuleNameValid = false;
|
||||
}
|
||||
this.inNameChecking = false;
|
||||
})
|
||||
.catch(() => {
|
||||
}, () => {
|
||||
this.inNameChecking = false;
|
||||
});
|
||||
} else {
|
||||
@ -179,7 +178,8 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
sourceChange($event): void {
|
||||
|
||||
sourceChange($event): void {
|
||||
if ($event && $event.target) {
|
||||
if ($event.target["value"] === "-1") {
|
||||
this.noSelectedEndpoint = true;
|
||||
@ -190,6 +190,38 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
this.noSelectedEndpoint = false;
|
||||
}
|
||||
|
||||
this.proNameChecker
|
||||
.pipe(debounceTime(500))
|
||||
.pipe(distinctUntilChanged())
|
||||
.subscribe((resp: string) => {
|
||||
let name = this.ruleForm.controls["projects"].value[0].name;
|
||||
this.noProjectInfo = "";
|
||||
this.selectedProjectList = [];
|
||||
this.proService.listProjects(name, undefined)
|
||||
.subscribe((res: any) => {
|
||||
if (res) {
|
||||
this.selectedProjectList = res.slice(0, 10);
|
||||
// if input value exit in project list
|
||||
let pro = res.find((data: any) => data.name === name);
|
||||
if (!pro) {
|
||||
this.noProjectInfo = "REPLICATION.NO_PROJECT_INFO";
|
||||
this.noSelectedProject = true;
|
||||
} else {
|
||||
this.noProjectInfo = "";
|
||||
this.noSelectedProject = false;
|
||||
this.setProject([pro]);
|
||||
}
|
||||
} else {
|
||||
this.noProjectInfo = "REPLICATION.NO_PROJECT_INFO";
|
||||
this.noSelectedProject = true;
|
||||
}
|
||||
}, (error: any) => {
|
||||
this.errorHandler.error(error);
|
||||
this.noProjectInfo = "REPLICATION.NO_PROJECT_INFO";
|
||||
this.noSelectedProject = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
@ -240,7 +272,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
||||
trigger: {
|
||||
kind: this.triggerNames[0],
|
||||
schedule_param: {
|
||||
cron: ""
|
||||
cron: ""
|
||||
}
|
||||
},
|
||||
deletion: false
|
||||
@ -614,30 +646,28 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
||||
if (this.policyId < 0) {
|
||||
this.repService
|
||||
.createReplicationRule(copyRuleForm)
|
||||
.then(() => {
|
||||
.subscribe(() => {
|
||||
this.translateService
|
||||
.get("REPLICATION.CREATED_SUCCESS")
|
||||
.subscribe(res => this.errorHandler.info(res));
|
||||
this.inProgress = false;
|
||||
this.reload.emit(true);
|
||||
this.close();
|
||||
})
|
||||
.catch((error: any) => {
|
||||
}, (error: any) => {
|
||||
this.inProgress = false;
|
||||
this.inlineAlert.showInlineError(error);
|
||||
});
|
||||
} else {
|
||||
this.repService
|
||||
.updateReplicationRule(this.policyId, this.ruleForm.value)
|
||||
.then(() => {
|
||||
.subscribe(() => {
|
||||
this.translateService
|
||||
.get("REPLICATION.UPDATED_SUCCESS")
|
||||
.subscribe(res => this.errorHandler.info(res));
|
||||
this.inProgress = false;
|
||||
this.reload.emit(true);
|
||||
this.close();
|
||||
})
|
||||
.catch((error: any) => {
|
||||
}, (error: any) => {
|
||||
this.inProgress = false;
|
||||
this.inlineAlert.showInlineError(error);
|
||||
});
|
||||
@ -677,16 +707,15 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
||||
if (ruleId) {
|
||||
this.policyId = +ruleId;
|
||||
this.headerTitle = "REPLICATION.EDIT_POLICY_TITLE";
|
||||
toPromise(this.repService.getReplicationRule(ruleId))
|
||||
.then(response => {
|
||||
this.repService.getReplicationRule(ruleId)
|
||||
.subscribe(response => {
|
||||
this.copyUpdateForm = clone(response);
|
||||
// set filter value is [] if callback filter value is null.
|
||||
this.updateForm(response);
|
||||
// keep trigger same value
|
||||
this.copyUpdateForm.trigger = clone(response.trigger);
|
||||
this.copyUpdateForm.filters = this.copyUpdateForm.filters === null ? [] : this.copyUpdateForm.filters;
|
||||
})
|
||||
.catch((error: any) => {
|
||||
}, (error: any) => {
|
||||
this.inlineAlert.showInlineError(error);
|
||||
});
|
||||
} else {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import {Component, Input, OnInit, OnChanges, Output, EventEmitter, ChangeDetectorRef, SimpleChanges} from "@angular/core";
|
||||
import {LabelService} from "../service/label.service";
|
||||
import {toPromise} from "../utils";
|
||||
import {Label} from "../service/interface";
|
||||
import {ErrorHandler} from "../error-handler/error-handler";
|
||||
import {Subject} from "rxjs";
|
||||
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
|
||||
import { Component, Input, OnInit, OnChanges, Output, EventEmitter, ChangeDetectorRef, SimpleChanges } from "@angular/core";
|
||||
import { LabelService } from "../service/label.service";
|
||||
import { Label } from "../service/interface";
|
||||
import { ErrorHandler } from "../error-handler/error-handler";
|
||||
import { Subject, forkJoin, Observable, throwError as observableThrowError } from "rxjs";
|
||||
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
|
||||
export interface LabelState {
|
||||
iconsShow: boolean;
|
||||
@ -22,7 +22,7 @@ export class FilterLabelComponent implements OnInit, OnChanges {
|
||||
openFilterLabelPanel: boolean;
|
||||
labelLists: LabelState[] = [];
|
||||
filterLabelName = '';
|
||||
labelNameFilter: Subject<string> = new Subject<string> ();
|
||||
labelNameFilter: Subject<string> = new Subject<string>();
|
||||
@Input() isOpen: boolean;
|
||||
@Input() projectId: number;
|
||||
@Input() selectedLabelInfo: Label[];
|
||||
@ -30,17 +30,19 @@ export class FilterLabelComponent implements OnInit, OnChanges {
|
||||
@Output() closePanelEvent = new EventEmitter();
|
||||
|
||||
constructor(private labelService: LabelService,
|
||||
private ref: ChangeDetectorRef,
|
||||
private errorHandler: ErrorHandler) {}
|
||||
private ref: ChangeDetectorRef,
|
||||
private errorHandler: ErrorHandler) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
Promise.all([this.getGLabels(), this.getPLabels()]).then(() => {
|
||||
forkJoin(this.getGLabels(), this.getPLabels()).subscribe(() => {
|
||||
this.selectedLabelInfo.forEach(info => {
|
||||
if (this.labelLists.length) {
|
||||
let lab = this.labelLists.find(data => data.label.id === info.id);
|
||||
if (lab) {this.selectOper(lab); }
|
||||
if (lab) { this.selectOper(lab); }
|
||||
}
|
||||
});
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
|
||||
this.labelNameFilter
|
||||
@ -64,32 +66,30 @@ export class FilterLabelComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes['isOpen']) {this.openFilterLabelPanel = changes['isOpen'].currentValue; }
|
||||
if (changes['isOpen']) { this.openFilterLabelPanel = changes['isOpen'].currentValue; }
|
||||
}
|
||||
|
||||
getGLabels() {
|
||||
return toPromise<Label[]>(this.labelService.getGLabels()).then((res: Label[]) => {
|
||||
return this.labelService.getGLabels().pipe(map((res: Label[]) => {
|
||||
if (res.length) {
|
||||
res.forEach(data => {
|
||||
this.labelLists.push({'iconsShow': false, 'label': data, 'show': true});
|
||||
this.labelLists.push({ 'iconsShow': false, 'label': data, 'show': true });
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
})
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
getPLabels() {
|
||||
if (this.projectId && this.projectId > 0) {
|
||||
return toPromise<Label[]>(this.labelService.getPLabels(this.projectId)).then((res1: Label[]) => {
|
||||
return this.labelService.getPLabels(this.projectId).pipe(map((res1: Label[]) => {
|
||||
if (res1.length) {
|
||||
res1.forEach(data => {
|
||||
this.labelLists.push({'iconsShow': false, 'label': data, 'show': true});
|
||||
this.labelLists.push({ 'iconsShow': false, 'label': data, 'show': true });
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
})
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ import { IServiceConfig, SERVICE_CONFIG } from "../service.config";
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
|
||||
import { click } from "../utils";
|
||||
import { of } from "rxjs";
|
||||
|
||||
describe("EndpointComponent (inline template)", () => {
|
||||
let mockData: Endpoint[] = [
|
||||
@ -138,7 +139,7 @@ describe("EndpointComponent (inline template)", () => {
|
||||
endpointService = fixture.debugElement.injector.get(EndpointService);
|
||||
|
||||
spy = spyOn(endpointService, "getEndpoints").and.returnValues(
|
||||
Promise.resolve(mockData)
|
||||
of(mockData)
|
||||
);
|
||||
|
||||
spyAdapter = spyOn(endpointService, "getAdapters").and.returnValue(
|
||||
@ -150,7 +151,7 @@ describe("EndpointComponent (inline template)", () => {
|
||||
"getEndpointWithReplicationRules"
|
||||
).and.returnValue([]);
|
||||
spyOne = spyOn(endpointService, "getEndpoint").and.returnValue(
|
||||
Promise.resolve(mockOne[0])
|
||||
of(mockOne[0])
|
||||
);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
@ -19,8 +19,7 @@ import {
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef
|
||||
} from "@angular/core";
|
||||
import { Subscription } from "rxjs";
|
||||
import { forkJoin } from "rxjs";
|
||||
import { Subscription, Observable, forkJoin } from "rxjs";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { Comparator } from "../service/interface";
|
||||
|
||||
@ -28,7 +27,7 @@ import { Endpoint } from "../service/interface";
|
||||
import { EndpointService } from "../service/endpoint.service";
|
||||
|
||||
import { ErrorHandler } from "../error-handler/index";
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { ConfirmationMessage } from "../confirmation-dialog/confirmation-message";
|
||||
import { ConfirmationAcknowledgement } from "../confirmation-dialog/confirmation-state-message";
|
||||
import { ConfirmationDialogComponent } from "../confirmation-dialog/confirmation-dialog.component";
|
||||
@ -40,7 +39,7 @@ import {
|
||||
} from "../shared/shared.const";
|
||||
|
||||
import { CreateEditEndpointComponent } from "../create-edit-endpoint/create-edit-endpoint.component";
|
||||
import { toPromise, CustomComparator } from "../utils";
|
||||
import { CustomComparator } from "../utils";
|
||||
|
||||
import { operateChanges, OperateInfo, OperationState } from "../operation/operate";
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
@ -116,13 +115,12 @@ export class EndpointComponent implements OnInit, OnDestroy {
|
||||
retrieve(): void {
|
||||
this.loading = true;
|
||||
this.selectedRow = [];
|
||||
toPromise<Endpoint[]>(this.endpointService.getEndpoints(this.targetName))
|
||||
.then(targets => {
|
||||
this.endpointService.getEndpoints(this.targetName)
|
||||
.subscribe(targets => {
|
||||
this.targets = targets || [];
|
||||
this.forceRefreshView(1000);
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
this.loading = false;
|
||||
});
|
||||
@ -182,11 +180,11 @@ export class EndpointComponent implements OnInit, OnDestroy {
|
||||
message.state === ConfirmationState.CONFIRMED) {
|
||||
let targetLists: Endpoint[] = message.data;
|
||||
if (targetLists && targetLists.length) {
|
||||
let promiseLists: any[] = [];
|
||||
let observableLists: any[] = [];
|
||||
targetLists.forEach(target => {
|
||||
promiseLists.push(this.delOperate(target));
|
||||
observableLists.push(this.delOperate(target));
|
||||
});
|
||||
Promise.all(promiseLists).then((item) => {
|
||||
forkJoin(...observableLists).subscribe((item) => {
|
||||
this.selectedRow = [];
|
||||
this.reload(true);
|
||||
this.forceRefreshView(2000);
|
||||
@ -194,8 +192,7 @@ export class EndpointComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delOperate(target: Endpoint) {
|
||||
delOperate(target: Endpoint): Observable<any> {
|
||||
// init operation info
|
||||
let operMessage = new OperateInfo();
|
||||
operMessage.name = 'OPERATION.DELETE_REGISTRY';
|
||||
@ -204,27 +201,29 @@ export class EndpointComponent implements OnInit, OnDestroy {
|
||||
operMessage.data.name = target.name;
|
||||
this.operationService.publishInfo(operMessage);
|
||||
|
||||
return toPromise<number>(this.endpointService
|
||||
.deleteEndpoint(target.id))
|
||||
.then(
|
||||
return this.endpointService
|
||||
.deleteEndpoint(target.id)
|
||||
.pipe(map(
|
||||
response => {
|
||||
this.translateService.get('BATCH.DELETED_SUCCESS')
|
||||
.subscribe(res => {
|
||||
operateChanges(operMessage, OperationState.success);
|
||||
});
|
||||
}).catch(
|
||||
error => {
|
||||
if (error && error.status === 412) {
|
||||
forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('DESTINATION.FAILED_TO_DELETE_TARGET_IN_USED')).subscribe(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res[1]);
|
||||
});
|
||||
} else {
|
||||
this.translateService.get('BATCH.DELETED_FAILURE').subscribe(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res);
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
, catchError(error => {
|
||||
if (error && error.status === 412) {
|
||||
return forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('DESTINATION.FAILED_TO_DELETE_TARGET_IN_USED')).pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res[1]);
|
||||
}));
|
||||
} else {
|
||||
return this.translateService.get('BATCH.DELETED_FAILURE').pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res);
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
// Forcely refresh the view
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
ChangeDetectorRef
|
||||
} from "@angular/core";
|
||||
|
||||
import { downloadFile, toPromise } from "../../utils";
|
||||
import { downloadFile } from "../../utils";
|
||||
import { SystemInfoService, HelmChartService } from "../../service/index";
|
||||
import { HelmChartDetail, SystemInfo } from "./../../service/interface";
|
||||
import { ErrorHandler } from "./../../error-handler/error-handler";
|
||||
@ -43,16 +43,15 @@ export class ChartDetailComponent implements OnInit {
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
toPromise<SystemInfo>(this.systemInfoService.getSystemInfo())
|
||||
.then(systemInfo => {
|
||||
this.systemInfoService.getSystemInfo()
|
||||
.subscribe(systemInfo => {
|
||||
let scheme = 'http://';
|
||||
this.systemInfo = systemInfo;
|
||||
if (this.systemInfo.has_ca_root) {
|
||||
scheme = 'https://';
|
||||
}
|
||||
this.repoURL = `${scheme}${this.systemInfo.registry_url}`;
|
||||
})
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
}, error => this.errorHandler.error(error));
|
||||
this.refresh();
|
||||
}
|
||||
public get chartNameWithVersion() {
|
||||
|
@ -15,7 +15,7 @@ import { forkJoin, throwError, Observable } from "rxjs";
|
||||
import { finalize, map, catchError } from "rxjs/operators";
|
||||
import { SystemInfo, SystemInfoService, HelmChartItem } from "../service/index";
|
||||
import { ErrorHandler } from "../error-handler/error-handler";
|
||||
import { toPromise, DEFAULT_PAGE_SIZE, downloadFile } from "../utils";
|
||||
import { DEFAULT_PAGE_SIZE, downloadFile } from "../utils";
|
||||
import { HelmChartService } from "../service/helm-chart.service";
|
||||
import { DefaultHelmIcon } from "../shared/shared.const";
|
||||
import { Roles } from './../shared/shared.const';
|
||||
@ -96,9 +96,9 @@ export class HelmChartComponent implements OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
// Get system info for tag views
|
||||
toPromise<SystemInfo>(this.systemInfoService.getSystemInfo())
|
||||
.then(systemInfo => (this.systemInfo = systemInfo))
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
this.systemInfoService.getSystemInfo()
|
||||
.subscribe(systemInfo => (this.systemInfo = systemInfo)
|
||||
, error => this.errorHandler.error(error));
|
||||
this.lastFilteredChartName = "";
|
||||
this.refresh();
|
||||
this.getHelmPermissionRule(this.projectId);
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
} from "./../../service/index";
|
||||
import { Label } from './../../service/interface';
|
||||
import { ErrorHandler } from "./../../error-handler/error-handler";
|
||||
import { toPromise, DEFAULT_PAGE_SIZE, downloadFile } from "../../utils";
|
||||
import { DEFAULT_PAGE_SIZE, downloadFile } from "../../utils";
|
||||
import { OperationService } from "./../../operation/operation.service";
|
||||
import { HelmChartService } from "./../../service/helm-chart.service";
|
||||
import { UserPermissionService } from "../../service/permission.service";
|
||||
@ -104,9 +104,9 @@ export class ChartVersionComponent implements OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
// Get system info for tag views
|
||||
toPromise<SystemInfo>(this.systemInfoService.getSystemInfo())
|
||||
.then(systemInfo => (this.systemInfo = systemInfo))
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
this.systemInfoService.getSystemInfo()
|
||||
.subscribe(systemInfo => (this.systemInfo = systemInfo)
|
||||
, error => this.errorHandler.error(error));
|
||||
this.refresh();
|
||||
this.getLabels();
|
||||
this.lastFilteredVersionName = "";
|
||||
|
@ -8,6 +8,7 @@ import { ProjectDefaultService, ProjectService } from "../service/index";
|
||||
import { ChannelService } from "../channel/index";
|
||||
import { Project } from "../project-policy-config/project";
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../service.config";
|
||||
import { of } from "rxjs";
|
||||
|
||||
describe("ImageNameInputComponent (inline template)", () => {
|
||||
let comp: ImageNameInputComponent;
|
||||
@ -54,7 +55,7 @@ describe("ImageNameInputComponent (inline template)", () => {
|
||||
|
||||
let projectService: ProjectService;
|
||||
projectService = fixture.debugElement.injector.get(ProjectService);
|
||||
spy = spyOn(projectService, "listProjects").and.returnValues(Promise.resolve(mockProjects));
|
||||
spy = spyOn(projectService, "listProjects").and.returnValues(of(mockProjects));
|
||||
});
|
||||
|
||||
it("should load data", async(() => {
|
||||
|
@ -13,6 +13,7 @@ import {ErrorHandler} from "../error-handler/error-handler";
|
||||
|
||||
import {IServiceConfig, SERVICE_CONFIG} from "../service.config";
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
import { of } from "rxjs";
|
||||
|
||||
describe('LabelComponent (inline template)', () => {
|
||||
|
||||
@ -91,8 +92,8 @@ describe('LabelComponent (inline template)', () => {
|
||||
|
||||
labelService = fixture.debugElement.injector.get(LabelService);
|
||||
|
||||
spy = spyOn(labelService, 'getLabels').and.returnValues(Promise.resolve(mockData));
|
||||
spyOneLabel = spyOn(labelService, 'getLabel').and.returnValues(Promise.resolve(mockOneData));
|
||||
spy = spyOn(labelService, 'getLabels').and.returnValues(of(mockData));
|
||||
spyOneLabel = spyOn(labelService, 'getLabel').and.returnValues(of(mockOneData));
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
|
@ -21,7 +21,6 @@ import {
|
||||
} from "@angular/core";
|
||||
import { Label } from "../service/interface";
|
||||
import { LabelService } from "../service/label.service";
|
||||
import { toPromise } from "../utils";
|
||||
import { ErrorHandler } from "../error-handler/error-handler";
|
||||
import { CreateEditLabelComponent } from "../create-edit-label/create-edit-label.component";
|
||||
import { ConfirmationMessage } from "../confirmation-dialog/confirmation-message";
|
||||
@ -35,7 +34,8 @@ import { TranslateService } from "@ngx-translate/core";
|
||||
import { ConfirmationDialogComponent } from "../confirmation-dialog/confirmation-dialog.component";
|
||||
import { operateChanges, OperateInfo, OperationState } from "../operation/operate";
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError, forkJoin } from "rxjs";
|
||||
@Component({
|
||||
selector: "hbr-label",
|
||||
templateUrl: "./label.component.html",
|
||||
@ -75,13 +75,12 @@ export class LabelComponent implements OnInit {
|
||||
this.loading = true;
|
||||
this.selectedRow = [];
|
||||
this.targetName = "";
|
||||
toPromise<Label[]>(this.labelService.getLabels(scope, this.projectId, name))
|
||||
.then(targets => {
|
||||
this.labelService.getLabels(scope, this.projectId, name)
|
||||
.subscribe(targets => {
|
||||
this.targets = targets || [];
|
||||
this.loading = false;
|
||||
this.forceRefreshView(2000);
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
this.loading = false;
|
||||
});
|
||||
@ -134,11 +133,11 @@ export class LabelComponent implements OnInit {
|
||||
message.state === ConfirmationState.CONFIRMED) {
|
||||
let targetLists: Label[] = message.data;
|
||||
if (targetLists && targetLists.length) {
|
||||
let promiseLists: any[] = [];
|
||||
let observableLists: any[] = [];
|
||||
targetLists.forEach(target => {
|
||||
promiseLists.push(this.delOperate(target));
|
||||
observableLists.push(this.delOperate(target));
|
||||
});
|
||||
Promise.all(promiseLists).then((item) => {
|
||||
forkJoin(...observableLists).subscribe((item) => {
|
||||
this.selectedRow = [];
|
||||
this.retrieve(this.scope);
|
||||
});
|
||||
@ -146,7 +145,7 @@ export class LabelComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
delOperate(target: Label) {
|
||||
delOperate(target: Label): Observable<any> {
|
||||
// init operation info
|
||||
let operMessage = new OperateInfo();
|
||||
operMessage.name = 'OPERATION.DELETE_LABEL';
|
||||
@ -155,20 +154,19 @@ export class LabelComponent implements OnInit {
|
||||
operMessage.data.name = target.name;
|
||||
this.operationService.publishInfo(operMessage);
|
||||
|
||||
return toPromise<number>(this.labelService
|
||||
.deleteLabel(target.id))
|
||||
.then(
|
||||
return this.labelService
|
||||
.deleteLabel(target.id)
|
||||
.pipe(map(
|
||||
response => {
|
||||
this.translateService.get('BATCH.DELETED_SUCCESS')
|
||||
.subscribe(res => {
|
||||
operateChanges(operMessage, OperationState.success);
|
||||
});
|
||||
}).catch(
|
||||
error => {
|
||||
this.translateService.get('BATCH.DELETED_FAILURE').subscribe(res => {
|
||||
}), catchError( error => {
|
||||
return this.translateService.get('BATCH.DELETED_FAILURE').pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res);
|
||||
});
|
||||
});
|
||||
}));
|
||||
}));
|
||||
}
|
||||
|
||||
// Forcely refresh the view
|
||||
|
@ -14,6 +14,7 @@ import { ErrorHandler } from '../error-handler/error-handler';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../service.config';
|
||||
import { ReplicationService, ReplicationDefaultService } from '../service/replication.service';
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('ListReplicationRuleComponent (inline template)', () => {
|
||||
|
||||
@ -77,7 +78,7 @@ describe('ListReplicationRuleComponent (inline template)', () => {
|
||||
fixture = TestBed.createComponent(ListReplicationRuleComponent);
|
||||
comp = fixture.componentInstance;
|
||||
replicationService = fixture.debugElement.injector.get(ReplicationService);
|
||||
spyRules = spyOn(replicationService, 'getReplicationRules').and.returnValues(Promise.resolve(mockRules));
|
||||
spyRules = spyOn(replicationService, 'getReplicationRules').and.returnValues(of(mockRules));
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
|
@ -24,10 +24,10 @@ import {
|
||||
SimpleChange,
|
||||
SimpleChanges
|
||||
} from "@angular/core";
|
||||
import { forkJoin } from "rxjs";
|
||||
import { Comparator } from "../service/interface";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, forkJoin, throwError as observableThrowError } from "rxjs";
|
||||
import { ReplicationService } from "../service/replication.service";
|
||||
|
||||
import {
|
||||
@ -44,7 +44,7 @@ import {
|
||||
ConfirmationButtons
|
||||
} from "../shared/shared.const";
|
||||
import { ErrorHandler } from "../error-handler/error-handler";
|
||||
import { toPromise, CustomComparator } from "../utils";
|
||||
import { CustomComparator } from "../utils";
|
||||
import { operateChanges, OperateInfo, OperationState } from "../operation/operate";
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
|
||||
@ -134,17 +134,14 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
|
||||
retrieveRules(ruleName = ""): void {
|
||||
this.loading = true;
|
||||
/*this.selectedRow = null;*/
|
||||
toPromise<ReplicationRule[]>(
|
||||
this.replicationService.getReplicationRules(this.projectId, ruleName)
|
||||
)
|
||||
.then(rules => {
|
||||
.subscribe(rules => {
|
||||
this.rules = rules || [];
|
||||
// job list hidden
|
||||
this.hideJobs.emit();
|
||||
this.changedRules = this.rules;
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
this.loading = false;
|
||||
});
|
||||
@ -198,12 +195,13 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
|
||||
this.editOne.emit(rule);
|
||||
}
|
||||
|
||||
jobList(id: string | number): Promise<void> {
|
||||
jobList(id: string | number): Observable<void> {
|
||||
let ruleData: ReplicationJobItem[];
|
||||
this.canDeleteRule = true;
|
||||
let count = 0;
|
||||
return toPromise<ReplicationJob>(this.replicationService.getExecutions(id))
|
||||
.then(response => {
|
||||
|
||||
return this.replicationService.getExecutions(id)
|
||||
.pipe(map(response => {
|
||||
ruleData = response.data;
|
||||
if (ruleData.length) {
|
||||
ruleData.forEach(job => {
|
||||
@ -217,8 +215,7 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
|
||||
});
|
||||
}
|
||||
this.canDeleteRule = count > 0 ? false : true;
|
||||
})
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
}), catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
deleteRule(rule: ReplicationRule) {
|
||||
@ -237,11 +234,11 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
|
||||
|
||||
deleteOpe(rule: ReplicationRule) {
|
||||
if (rule) {
|
||||
let promiseLists: any[] = [];
|
||||
Promise.all([this.jobList(rule.id)]).then(items => {
|
||||
promiseLists.push(this.delOperate(rule));
|
||||
let observableLists: any[] = [];
|
||||
this.jobList(rule.id).subscribe(items => {
|
||||
observableLists.push(this.delOperate(rule));
|
||||
|
||||
Promise.all(promiseLists).then(item => {
|
||||
forkJoin(...observableLists).subscribe(item => {
|
||||
this.selectedRow = null;
|
||||
this.reload.emit(true);
|
||||
let hnd = setInterval(() => this.ref.markForCheck(), 200);
|
||||
@ -251,7 +248,7 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
delOperate(rule: ReplicationRule) {
|
||||
delOperate(rule: ReplicationRule): Observable<any> {
|
||||
// init operation info
|
||||
let operMessage = new OperateInfo();
|
||||
operMessage.name = 'OPERATION.DELETE_REPLICATION';
|
||||
@ -261,30 +258,29 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
|
||||
this.operationService.publishInfo(operMessage);
|
||||
|
||||
if (!this.canDeleteRule) {
|
||||
forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPLICATION.DELETION_SUMMARY_FAILURE')).subscribe(res => {
|
||||
return forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPLICATION.DELETION_SUMMARY_FAILURE')).pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res[1]);
|
||||
});
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
return toPromise<any>(this.replicationService
|
||||
.deleteReplicationRule(+rule.id))
|
||||
.then(() => {
|
||||
return this.replicationService
|
||||
.deleteReplicationRule(+rule.id)
|
||||
.pipe(map(() => {
|
||||
this.translateService.get('BATCH.DELETED_SUCCESS')
|
||||
.subscribe(res => operateChanges(operMessage, OperationState.success));
|
||||
})
|
||||
.catch(error => {
|
||||
, catchError(error => {
|
||||
if (error && error.status === 412) {
|
||||
forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPLICATION.FAILED_TO_DELETE_POLICY_ENABLED')).subscribe(res => {
|
||||
return forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPLICATION.FAILED_TO_DELETE_POLICY_ENABLED')).pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res[1]);
|
||||
});
|
||||
}));
|
||||
} else {
|
||||
this.translateService.get('BATCH.DELETED_FAILURE').subscribe(res => {
|
||||
return this.translateService.get('BATCH.DELETED_FAILURE').pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res);
|
||||
});
|
||||
}));
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ import { SharedModule } from '../shared/shared.module';
|
||||
import { FilterComponent } from '../filter/filter.component';
|
||||
|
||||
import { click } from '../utils';
|
||||
import { of } from 'rxjs';
|
||||
import { startWith, delay } from 'rxjs/operators';
|
||||
|
||||
describe('RecentLogComponent (inline template)', () => {
|
||||
let component: RecentLogComponent;
|
||||
@ -74,23 +76,19 @@ describe('RecentLogComponent (inline template)', () => {
|
||||
spy = spyOn(logService, 'getRecentLogs')
|
||||
.and.callFake(function (params: RequestQueryParams) {
|
||||
if (params && params.get('username')) {
|
||||
return Promise.resolve(mockData2);
|
||||
return of(mockData2).pipe(delay(0));
|
||||
} else {
|
||||
if (params.get('page') === '1') {
|
||||
mockData.data = mockItems.slice(0, 15);
|
||||
} else {
|
||||
mockData.data = mockItems.slice(15, 18);
|
||||
}
|
||||
return Promise.resolve(mockData);
|
||||
return of(mockData).pipe(delay(0));
|
||||
}
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
afterEach(() => {
|
||||
mockItems = [];
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
|
@ -21,7 +21,7 @@ import {
|
||||
RequestQueryParams
|
||||
} from '../service/index';
|
||||
import { ErrorHandler } from '../error-handler/index';
|
||||
import { toPromise, CustomComparator } from '../utils';
|
||||
import { CustomComparator } from '../utils';
|
||||
import {
|
||||
DEFAULT_PAGE_SIZE,
|
||||
calculatePage,
|
||||
@ -127,8 +127,8 @@ export class RecentLogComponent implements OnInit {
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
toPromise<AccessLog>(this.logService.getRecentLogs(params))
|
||||
.then(response => {
|
||||
this.logService.getRecentLogs(params)
|
||||
.subscribe(response => {
|
||||
this.logsCache = response; // Keep the data
|
||||
this.recentLogs = this.logsCache.data.filter(log => log.username !== ""); // To display
|
||||
|
||||
@ -141,8 +141,7 @@ export class RecentLogComponent implements OnInit {
|
||||
this.currentPagePvt = pageNumber;
|
||||
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.loading = false;
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
|
@ -121,8 +121,8 @@ describe('ProjectPolicyConfigComponent', () => {
|
||||
systemInfoService = fixture.debugElement.injector.get(SystemInfoService);
|
||||
projectPolicyService = fixture.debugElement.injector.get(ProjectService);
|
||||
|
||||
spySystemInfo = spyOn(systemInfoService, 'getSystemInfo').and.returnValues(Promise.resolve(mockSystemInfo[0]));
|
||||
spyProjectPolicies = spyOn(projectPolicyService, 'getProject').and.returnValues(Promise.resolve(mockProjectPolicies[0]));
|
||||
spySystemInfo = spyOn(systemInfoService, 'getSystemInfo').and.returnValues(of(mockSystemInfo[0]));
|
||||
spyProjectPolicies = spyOn(projectPolicyService, 'getProject').and.returnValues(of(mockProjectPolicies[0]));
|
||||
|
||||
userPermissionService = fixture.debugElement.injector.get(UserPermissionService);
|
||||
spyOn(userPermissionService, "getPermission")
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
|
||||
import { toPromise, compareValue, clone } from '../utils';
|
||||
import { compareValue, clone } from '../utils';
|
||||
import { ProjectService } from '../service/project.service';
|
||||
import { ErrorHandler } from '../error-handler/error-handler';
|
||||
import { State } from '../service/interface';
|
||||
@ -82,9 +82,9 @@ export class ProjectPolicyConfigComponent implements OnInit {
|
||||
}
|
||||
|
||||
// get system info
|
||||
toPromise<SystemInfo>(this.systemInfoService.getSystemInfo())
|
||||
.then(systemInfo => this.systemInfo = systemInfo)
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
this.systemInfoService.getSystemInfo()
|
||||
.subscribe(systemInfo => this.systemInfo = systemInfo
|
||||
, error => this.errorHandler.error(error));
|
||||
|
||||
// retrive project level policy data
|
||||
this.retrieve();
|
||||
@ -105,13 +105,12 @@ export class ProjectPolicyConfigComponent implements OnInit {
|
||||
}
|
||||
|
||||
retrieve(state?: State): any {
|
||||
toPromise<Project>(this.projectService.getProject(this.projectId))
|
||||
.then(
|
||||
this.projectService.getProject(this.projectId)
|
||||
.subscribe(
|
||||
response => {
|
||||
this.orgProjectPolicy.initByProject(response);
|
||||
this.projectPolicy.initByProject(response);
|
||||
})
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
}, error => this.errorHandler.error(error));
|
||||
}
|
||||
|
||||
updateProjectPolicy(projectId: string|number, pp: ProjectPolicy) {
|
||||
@ -139,16 +138,15 @@ export class ProjectPolicyConfigComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
this.onGoing = true;
|
||||
toPromise<any>(this.projectService.updateProjectPolicy(this.projectId, this.projectPolicy))
|
||||
.then(() => {
|
||||
this.projectService.updateProjectPolicy(this.projectId, this.projectPolicy)
|
||||
.subscribe(() => {
|
||||
this.onGoing = false;
|
||||
|
||||
this.translate.get('CONFIG.SAVE_SUCCESS').subscribe((res: string) => {
|
||||
this.errorHandler.info(res);
|
||||
});
|
||||
this.refresh();
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
|
@ -23,6 +23,8 @@ import {OperationService} from "../operation/operation.service";
|
||||
import {FilterLabelComponent} from "../create-edit-rule/filter-label.component";
|
||||
import {LabelPieceComponent} from "../label-piece/label-piece.component";
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
|
||||
describe('Replication Component (inline template)', () => {
|
||||
|
||||
@ -181,10 +183,11 @@ describe('Replication Component (inline template)', () => {
|
||||
|
||||
endpointService = fixtureCreate.debugElement.injector.get(EndpointService);
|
||||
|
||||
spyRules = spyOn(replicationService, 'getReplicationRules').and.returnValues(Promise.resolve(mockRules));
|
||||
spyJobs = spyOn(replicationService, 'getExecutions').and.returnValues(Promise.resolve(mockJob));
|
||||
spyRules = spyOn(replicationService, 'getReplicationRules').and.returnValues(of(mockRules));
|
||||
spyJobs = spyOn(replicationService, 'getExecutions').and.returnValues(of(mockJob));
|
||||
|
||||
spyEndpoint = spyOn(endpointService, 'getEndpoints').and.returnValues(Promise.resolve(mockEndpoints));
|
||||
|
||||
spyEndpoint = spyOn(endpointService, 'getEndpoints').and.returnValues(of(mockEndpoints));
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
|
@ -21,9 +21,8 @@ import {
|
||||
EventEmitter
|
||||
} from "@angular/core";
|
||||
import { Comparator, State } from "../service/interface";
|
||||
import { Subscription, forkJoin, timer, throwError} from "rxjs";
|
||||
import { finalize, catchError, map } from "rxjs/operators";
|
||||
|
||||
import { Subscription, forkJoin, timer, Observable, throwError } from "rxjs";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
|
||||
import { ListReplicationRuleComponent } from "../list-replication-rule/list-replication-rule.component";
|
||||
@ -39,7 +38,6 @@ import {
|
||||
} from "../service/interface";
|
||||
|
||||
import {
|
||||
toPromise,
|
||||
CustomComparator,
|
||||
DEFAULT_PAGE_SIZE,
|
||||
doFiltering,
|
||||
@ -55,9 +53,8 @@ import {
|
||||
import { ConfirmationMessage } from "../confirmation-dialog/confirmation-message";
|
||||
import { ConfirmationDialogComponent } from "../confirmation-dialog/confirmation-dialog.component";
|
||||
import { ConfirmationAcknowledgement } from "../confirmation-dialog/confirmation-state-message";
|
||||
import {operateChanges, OperationState, OperateInfo} from "../operation/operate";
|
||||
import {OperationService} from "../operation/operation.service";
|
||||
|
||||
import { operateChanges, OperationState, OperateInfo } from "../operation/operate";
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
import { Router } from "@angular/router";
|
||||
|
||||
const ruleStatus: { [key: string]: any } = [
|
||||
@ -152,10 +149,10 @@ export class ReplicationComponent implements OnInit, OnDestroy {
|
||||
|
||||
creationTimeComparator: Comparator<ReplicationJob> = new CustomComparator<
|
||||
ReplicationJob
|
||||
>("start_time", "date");
|
||||
>("start_time", "date");
|
||||
updateTimeComparator: Comparator<ReplicationJob> = new CustomComparator<
|
||||
ReplicationJob
|
||||
>("end_time", "date");
|
||||
>("end_time", "date");
|
||||
|
||||
// Server driven pagination
|
||||
currentPage: number = 1;
|
||||
@ -170,7 +167,7 @@ export class ReplicationComponent implements OnInit, OnDestroy {
|
||||
private errorHandler: ErrorHandler,
|
||||
private replicationService: ReplicationService,
|
||||
private operationService: OperationService,
|
||||
private translateService: TranslateService) {}
|
||||
private translateService: TranslateService) { }
|
||||
|
||||
public get showPaginationIndex(): boolean {
|
||||
return this.totalCount > 0;
|
||||
@ -248,10 +245,9 @@ export class ReplicationComponent implements OnInit, OnDestroy {
|
||||
this.jobs = doSorting<ReplicationJobItem>(this.jobs, state);
|
||||
|
||||
this.jobsLoading = false;
|
||||
toPromise<ReplicationJob>(
|
||||
this.replicationService.getExecutions(this.search.ruleId, params)
|
||||
)
|
||||
.then(response => {
|
||||
|
||||
this.replicationService.getExecutions(this.search.ruleId, params)
|
||||
.subscribe(response => {
|
||||
this.totalCount = response.metadata.xTotalCount;
|
||||
this.jobs = response.data;
|
||||
|
||||
@ -281,8 +277,7 @@ export class ReplicationComponent implements OnInit, OnDestroy {
|
||||
this.jobs = doSorting<ReplicationJobItem>(this.jobs, state);
|
||||
|
||||
this.jobsLoading = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.jobsLoading = false;
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
@ -337,14 +332,14 @@ export class ReplicationComponent implements OnInit, OnDestroy {
|
||||
let rule: ReplicationRule = message.data;
|
||||
|
||||
if (rule) {
|
||||
Promise.all([this.replicationOperate(rule)]).then((item) => {
|
||||
forkJoin(this.replicationOperate(rule)).subscribe((item) => {
|
||||
this.selectOneRule(rule);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
replicationOperate(rule: ReplicationRule) {
|
||||
replicationOperate(rule: ReplicationRule): Observable<any> {
|
||||
// init operation info
|
||||
let operMessage = new OperateInfo();
|
||||
operMessage.name = 'OPERATION.REPLICATION';
|
||||
@ -353,24 +348,24 @@ export class ReplicationComponent implements OnInit, OnDestroy {
|
||||
operMessage.data.name = rule.name;
|
||||
this.operationService.publishInfo(operMessage);
|
||||
|
||||
return toPromise<any>(this.replicationService.replicateRule(+rule.id))
|
||||
.then(response => {
|
||||
this.translateService.get('BATCH.REPLICATE_SUCCESS')
|
||||
.subscribe(res => operateChanges(operMessage, OperationState.success));
|
||||
})
|
||||
.catch(error => {
|
||||
return this.replicationService.replicateRule(+rule.id)
|
||||
.pipe(map(response => {
|
||||
this.translateService.get('BATCH.REPLICATE_SUCCESS')
|
||||
.subscribe(res => operateChanges(operMessage, OperationState.success));
|
||||
})
|
||||
, catchError(error => {
|
||||
if (error && error.status === 412) {
|
||||
forkJoin(this.translateService.get('BATCH.REPLICATE_FAILURE'),
|
||||
this.translateService.get('REPLICATION.REPLICATE_SUMMARY_FAILURE'))
|
||||
.subscribe(function (res) {
|
||||
operateChanges(operMessage, OperationState.failure, res[1]);
|
||||
});
|
||||
return forkJoin(this.translateService.get('BATCH.REPLICATE_FAILURE'),
|
||||
this.translateService.get('REPLICATION.REPLICATE_SUMMARY_FAILURE'))
|
||||
.pipe(map(function (res) {
|
||||
operateChanges(operMessage, OperationState.failure, res[1]);
|
||||
}));
|
||||
} else {
|
||||
this.translateService.get('BATCH.REPLICATE_FAILURE').subscribe(res => {
|
||||
return this.translateService.get('BATCH.REPLICATE_FAILURE').pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res);
|
||||
});
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
customRedirect(rule: ReplicationRule) {
|
||||
@ -435,7 +430,7 @@ export class ReplicationComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
this.isStopOnGoing = true;
|
||||
if (this.jobs && this.jobs.length) {
|
||||
if (this.jobs && this.jobs.length) {
|
||||
let ExecutionsStop$ = targets.map(target => this.StopOperate(target));
|
||||
forkJoin(ExecutionsStop$)
|
||||
.pipe(
|
||||
|
@ -155,13 +155,13 @@ describe('RepositoryComponentGridview (inline template)', () => {
|
||||
repositoryService = fixtureRepo.debugElement.injector.get(RepositoryService);
|
||||
systemInfoService = fixtureRepo.debugElement.injector.get(SystemInfoService);
|
||||
|
||||
spySystemInfo = spyOn(systemInfoService, 'getSystemInfo').and.returnValues(Promise.resolve(mockSystemInfo));
|
||||
spySystemInfo = spyOn(systemInfoService, 'getSystemInfo').and.returnValues(of(mockSystemInfo));
|
||||
spyRepos = spyOn(repositoryService, 'getRepositories')
|
||||
.and.callFake(function (projectId: number, name: string) {
|
||||
if (name === 'nginx') {
|
||||
return Promise.resolve(mockNginxRepo);
|
||||
return of(mockNginxRepo);
|
||||
}
|
||||
return Promise.resolve(mockRepo);
|
||||
return of(mockRepo);
|
||||
});
|
||||
userPermissionService = fixtureRepo.debugElement.injector.get(UserPermissionService);
|
||||
spyOn(userPermissionService, "getPermission")
|
||||
|
@ -27,7 +27,7 @@ import {
|
||||
TagService
|
||||
} from '../service/index';
|
||||
import { ErrorHandler } from '../error-handler/error-handler';
|
||||
import { toPromise, CustomComparator, DEFAULT_PAGE_SIZE, calculatePage, doFiltering, doSorting, clone } from '../utils';
|
||||
import { CustomComparator, DEFAULT_PAGE_SIZE, calculatePage, doFiltering, doSorting, clone } from '../utils';
|
||||
import { ConfirmationState, ConfirmationTargets, ConfirmationButtons } from '../shared/shared.const';
|
||||
import { ConfirmationDialogComponent } from '../confirmation-dialog/confirmation-dialog.component';
|
||||
import { ConfirmationMessage } from '../confirmation-dialog/confirmation-message';
|
||||
@ -39,6 +39,8 @@ import { UserPermissionService } from "../service/permission.service";
|
||||
import { USERSTATICPERMISSION } from "../service/permission-static";
|
||||
import { OperateInfo, OperationState, operateChanges } from "../operation/operate";
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../service.config';
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
@Component({
|
||||
selector: "hbr-repository-gridview",
|
||||
templateUrl: "./repository-gridview.component.html",
|
||||
@ -134,9 +136,9 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
// Get system info for tag views
|
||||
toPromise<SystemInfo>(this.systemInfoService.getSystemInfo())
|
||||
.then(systemInfo => (this.systemInfo = systemInfo))
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
this.systemInfoService.getSystemInfo()
|
||||
.subscribe(systemInfo => (this.systemInfo = systemInfo)
|
||||
, error => this.errorHandler.error(error));
|
||||
|
||||
if (this.mode === "admiral") {
|
||||
this.isCardView = true;
|
||||
@ -155,12 +157,12 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
|
||||
let repoLists = message.data;
|
||||
if (repoLists && repoLists.length) {
|
||||
let promiseLists: any[] = [];
|
||||
let observableLists: any[] = [];
|
||||
repoLists.forEach(repo => {
|
||||
promiseLists.push(this.delOperate(repo));
|
||||
observableLists.push(this.delOperate(repo));
|
||||
});
|
||||
|
||||
Promise.all(promiseLists).then((item) => {
|
||||
forkJoin(observableLists).subscribe((item) => {
|
||||
this.selectedRow = [];
|
||||
this.refresh();
|
||||
let st: State = this.getStateAfterDeletion();
|
||||
@ -174,7 +176,7 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
delOperate(repo: RepositoryItem) {
|
||||
delOperate(repo: RepositoryItem): Observable<any> {
|
||||
// init operation info
|
||||
let operMessage = new OperateInfo();
|
||||
operMessage.name = 'OPERATION.DELETE_REPO';
|
||||
@ -184,37 +186,35 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
this.operationService.publishInfo(operMessage);
|
||||
|
||||
if (this.signedCon[repo.name].length !== 0) {
|
||||
forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPOSITORY.DELETION_TITLE_REPO_SIGNED')).subscribe(res => {
|
||||
return forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPOSITORY.DELETION_TITLE_REPO_SIGNED')).pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res[1]);
|
||||
});
|
||||
}));
|
||||
} else {
|
||||
return toPromise<number>(this.repositoryService
|
||||
.deleteRepository(repo.name))
|
||||
.then(
|
||||
return this.repositoryService
|
||||
.deleteRepository(repo.name)
|
||||
.pipe(map(
|
||||
response => {
|
||||
this.translateService.get('BATCH.DELETED_SUCCESS').subscribe(res => {
|
||||
operateChanges(operMessage, OperationState.success);
|
||||
});
|
||||
}).catch(error => {
|
||||
}), catchError(error => {
|
||||
if (error.status === "412") {
|
||||
forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPOSITORY.TAGS_SIGNED')).subscribe(res => {
|
||||
return forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPOSITORY.TAGS_SIGNED')).pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res[1]);
|
||||
});
|
||||
return;
|
||||
}));
|
||||
}
|
||||
if (error.status === 503) {
|
||||
forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPOSITORY.TAGS_NO_DELETE')).subscribe(res => {
|
||||
return forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPOSITORY.TAGS_NO_DELETE')).pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res[1]);
|
||||
});
|
||||
return;
|
||||
}));
|
||||
}
|
||||
this.translateService.get('BATCH.DELETED_FAILURE').subscribe(res => {
|
||||
return this.translateService.get('BATCH.DELETED_FAILURE').pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res);
|
||||
});
|
||||
});
|
||||
}));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all(repArr).then(() => {
|
||||
forkJoin(...repArr).subscribe(() => {
|
||||
this.confirmationDialogSet(
|
||||
'REPOSITORY.DELETION_TITLE_REPO',
|
||||
'',
|
||||
@ -256,21 +256,21 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
repoLists,
|
||||
'REPOSITORY.DELETION_SUMMARY_REPO',
|
||||
ConfirmationButtons.DELETE_CANCEL);
|
||||
});
|
||||
}, error => this.errorHandler.error(error));
|
||||
}
|
||||
}
|
||||
|
||||
getTagInfo(repoName: string): Promise<void> {
|
||||
getTagInfo(repoName: string): Observable<void> {
|
||||
this.signedCon[repoName] = [];
|
||||
return toPromise<Tag[]>(this.tagService.getTags(repoName))
|
||||
.then(items => {
|
||||
return this.tagService.getTags(repoName)
|
||||
.pipe(map(items => {
|
||||
items.forEach((t: Tag) => {
|
||||
if (t.signature !== null) {
|
||||
this.signedCon[repoName].push(t.name);
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
confirmationDialogSet(summaryTitle: string, signature: string,
|
||||
@ -299,9 +299,9 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
containsLatestTag(repo: RepositoryItem): Promise<boolean> {
|
||||
return toPromise<Tag[]>(this.tagService.getTags(repo.name))
|
||||
.then(items => {
|
||||
containsLatestTag(repo: RepositoryItem): Observable<boolean> {
|
||||
return this.tagService.getTags(repo.name)
|
||||
.pipe(map(items => {
|
||||
if (items.some((t: Tag) => {
|
||||
return t.name === 'latest';
|
||||
})) {
|
||||
@ -311,7 +311,7 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
}
|
||||
|
||||
})
|
||||
.catch(error => Promise.reject(false));
|
||||
, catchError(error => observableThrowError(false)));
|
||||
}
|
||||
|
||||
provisionItemEvent(evt: any, repo: RepositoryItem): void {
|
||||
@ -319,14 +319,13 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
let repoCopy = clone(repo);
|
||||
repoCopy.name = this.registryUrl + ":443/" + repoCopy.name;
|
||||
this.containsLatestTag(repo)
|
||||
.then(containsLatest => {
|
||||
.subscribe(containsLatest => {
|
||||
if (containsLatest) {
|
||||
this.repoProvisionEvent.emit(repoCopy);
|
||||
} else {
|
||||
this.addInfoEvent.emit(repoCopy);
|
||||
}
|
||||
})
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
}, error => this.errorHandler.error(error));
|
||||
|
||||
}
|
||||
|
||||
@ -359,14 +358,12 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
params.set("page_size", "" + this.pageSize);
|
||||
|
||||
this.loading = true;
|
||||
toPromise<Repository>(
|
||||
this.repositoryService.getRepositories(
|
||||
this.projectId,
|
||||
this.lastFilteredRepoName,
|
||||
params
|
||||
)
|
||||
)
|
||||
.then((repo: Repository) => {
|
||||
.subscribe((repo: Repository) => {
|
||||
this.totalCount = repo.metadata.xTotalCount;
|
||||
this.repositoriesCopy = repo.data;
|
||||
this.signedCon = {};
|
||||
@ -381,8 +378,7 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
);
|
||||
this.repositories = this.repositories.concat(this.repositoriesCopy);
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.loading = false;
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
@ -410,14 +406,12 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
|
||||
this.loading = true;
|
||||
|
||||
toPromise<Repository>(
|
||||
this.repositoryService.getRepositories(
|
||||
this.projectId,
|
||||
this.lastFilteredRepoName,
|
||||
params
|
||||
)
|
||||
)
|
||||
.then((repo: Repository) => {
|
||||
.subscribe((repo: Repository) => {
|
||||
|
||||
this.totalCount = repo.metadata.xTotalCount;
|
||||
this.repositories = repo.data;
|
||||
@ -430,8 +424,7 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit {
|
||||
);
|
||||
this.repositories = doSorting<RepositoryItem>(this.repositories, state);
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.loading = false;
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
|
@ -29,6 +29,7 @@ import { ProjectDefaultService, ProjectService, RetagDefaultService, RetagServic
|
||||
import { UserPermissionDefaultService, UserPermissionService } from "../service/permission.service";
|
||||
import { USERSTATICPERMISSION } from "../service/permission-static";
|
||||
import { of } from "rxjs";
|
||||
import { delay } from 'rxjs/operators';
|
||||
|
||||
|
||||
class RouterStub {
|
||||
@ -204,12 +205,12 @@ describe('RepositoryComponent (inline template)', () => {
|
||||
userPermissionService = fixture.debugElement.injector.get(UserPermissionService);
|
||||
labelService = fixture.debugElement.injector.get(LabelService);
|
||||
|
||||
spyRepos = spyOn(repositoryService, 'getRepositories').and.returnValues(Promise.resolve(mockRepo));
|
||||
spySystemInfo = spyOn(systemInfoService, 'getSystemInfo').and.returnValues(Promise.resolve(mockSystemInfo));
|
||||
spyTags = spyOn(tagService, 'getTags').and.returnValues(Promise.resolve(mockTagData));
|
||||
spyRepos = spyOn(repositoryService, 'getRepositories').and.returnValues(of(mockRepo).pipe(delay(0)));
|
||||
spySystemInfo = spyOn(systemInfoService, 'getSystemInfo').and.returnValues(of(mockSystemInfo).pipe(delay(0)));
|
||||
spyTags = spyOn(tagService, 'getTags').and.returnValues(of(mockTagData).pipe(delay(0)));
|
||||
|
||||
spyLabels = spyOn(labelService, 'getGLabels').and.returnValues(Promise.resolve(mockLabels));
|
||||
spyLabels1 = spyOn(labelService, 'getPLabels').and.returnValues(Promise.resolve(mockLabels1));
|
||||
spyLabels = spyOn(labelService, 'getGLabels').and.returnValues(of(mockLabels).pipe(delay(0)));
|
||||
spyLabels1 = spyOn(labelService, 'getPLabels').and.returnValues(of(mockLabels1).pipe(delay(0)));
|
||||
spyOn(userPermissionService, "getPermission")
|
||||
.withArgs(compRepo.projectId, USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.KEY, USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.VALUE.CREATE )
|
||||
.and.returnValue(of(mockHasAddLabelImagePermission))
|
||||
|
@ -21,8 +21,8 @@ import { Repository, RepositoryItem, Tag, TagClickEvent,
|
||||
import { ErrorHandler } from '../error-handler/index';
|
||||
import { ConfirmationState, ConfirmationTargets } from '../shared/shared.const';
|
||||
import { ConfirmationDialogComponent, ConfirmationMessage, ConfirmationAcknowledgement } from '../confirmation-dialog/index';
|
||||
import { toPromise } from '../utils';
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
const TabLinkContentMap: {[index: string]: string} = {
|
||||
'repo-info': 'info',
|
||||
'repo-image': 'image'
|
||||
@ -93,17 +93,15 @@ export class RepositoryComponent implements OnInit {
|
||||
}
|
||||
|
||||
retrieve(state?: State) {
|
||||
toPromise<Repository>(this.repositoryService.getRepositories(this.projectId, this.repoName))
|
||||
.then( response => {
|
||||
this.repositoryService.getRepositories(this.projectId, this.repoName)
|
||||
.subscribe( response => {
|
||||
if (response.metadata.xTotalCount > 0) {
|
||||
this.orgImageInfo = response.data[0].description;
|
||||
this.imageInfo = response.data[0].description;
|
||||
}
|
||||
})
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
toPromise<SystemInfo>(this.systemInfoService.getSystemInfo())
|
||||
.then(systemInfo => this.systemInfo = systemInfo)
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
}, error => this.errorHandler.error(error));
|
||||
this.systemInfoService.getSystemInfo()
|
||||
.subscribe(systemInfo => this.systemInfo = systemInfo, error => this.errorHandler.error(error));
|
||||
}
|
||||
|
||||
saveSignatures(event: {[key: string]: string[]}): void {
|
||||
@ -130,19 +128,19 @@ export class RepositoryComponent implements OnInit {
|
||||
this.currentTabID = tabID;
|
||||
}
|
||||
|
||||
getTagInfo(repoName: string): Promise<void> {
|
||||
getTagInfo(repoName: string): Observable<void> {
|
||||
// this.signedNameArr = [];
|
||||
this.signedCon[repoName] = [];
|
||||
return toPromise<Tag[]>(this.tagService
|
||||
.getTags(repoName))
|
||||
.then(items => {
|
||||
return this.tagService
|
||||
.getTags(repoName)
|
||||
.pipe(map(items => {
|
||||
items.forEach((t: Tag) => {
|
||||
if (t.signature !== null) {
|
||||
this.signedCon[repoName].push(t.name);
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
goBack(): void {
|
||||
@ -170,16 +168,15 @@ export class RepositoryComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
this.onGoing = true;
|
||||
toPromise<any>(this.repositoryService.updateRepositoryDescription(this.repoName, this.imageInfo))
|
||||
.then(() => {
|
||||
this.repositoryService.updateRepositoryDescription(this.repoName, this.imageInfo)
|
||||
.subscribe(() => {
|
||||
this.onGoing = false;
|
||||
this.translate.get('CONFIG.SAVE_SUCCESS').subscribe((res: string) => {
|
||||
this.errorHandler.info(res);
|
||||
});
|
||||
this.editing = false;
|
||||
this.refresh();
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { Observable, of } from "rxjs";
|
||||
import { Observable, of, throwError as observableThrowError } from "rxjs";
|
||||
import { RequestQueryParams } from "./RequestQueryParams";
|
||||
import { AccessLog, AccessLogItem } from "./interface";
|
||||
import { Injectable, Inject } from "@angular/core";
|
||||
import { SERVICE_CONFIG, IServiceConfig } from "../service.config";
|
||||
import { Http } from "@angular/http";
|
||||
import { buildHttpRequestOptions, HTTP_GET_OPTIONS } from "../utils";
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
|
||||
/**
|
||||
* Define service methods to handle the access log related things.
|
||||
@ -23,27 +24,27 @@ export abstract class AccessLogService {
|
||||
* @abstract
|
||||
* ** deprecated param {(number | string)} projectId
|
||||
* ** deprecated param {RequestQueryParams} [queryParams]
|
||||
* returns {(Observable<AccessLog> | Promise<AccessLog> | AccessLog)}
|
||||
* returns {(Observable<AccessLog> | AccessLog)}
|
||||
*
|
||||
* @memberOf AccessLogService
|
||||
*/
|
||||
abstract getAuditLogs(
|
||||
projectId: number | string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<AccessLog> | Promise<AccessLog> | AccessLog;
|
||||
): Observable<AccessLog>;
|
||||
|
||||
/**
|
||||
* Get the recent logs.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {RequestQueryParams} [queryParams]
|
||||
* returns {(Observable<AccessLog> | Promise<AccessLog> | AccessLog)}
|
||||
* returns {(Observable<AccessLog> | AccessLog)}
|
||||
*
|
||||
* @memberOf AccessLogService
|
||||
*/
|
||||
abstract getRecentLogs(
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<AccessLog> | Promise<AccessLog> | AccessLog;
|
||||
): Observable<AccessLog>;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,13 +66,13 @@ export class AccessLogDefaultService extends AccessLogService {
|
||||
public getAuditLogs(
|
||||
projectId: number | string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<AccessLog> | Promise<AccessLog> | AccessLog {
|
||||
): Observable<AccessLog> {
|
||||
return of({} as AccessLog);
|
||||
}
|
||||
|
||||
public getRecentLogs(
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<AccessLog> | Promise<AccessLog> | AccessLog {
|
||||
): Observable<AccessLog> {
|
||||
let url: string = this.config.logBaseEndpoint
|
||||
? this.config.logBaseEndpoint
|
||||
: "";
|
||||
@ -84,8 +85,7 @@ export class AccessLogDefaultService extends AccessLogService {
|
||||
url,
|
||||
queryParams ? buildHttpRequestOptions(queryParams) : HTTP_GET_OPTIONS
|
||||
)
|
||||
.toPromise()
|
||||
.then(response => {
|
||||
.pipe(map(response => {
|
||||
let result: AccessLog = {
|
||||
metadata: {
|
||||
xTotalCount: 0
|
||||
@ -106,6 +106,6 @@ export class AccessLogDefaultService extends AccessLogService {
|
||||
|
||||
return result;
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Injectable, Inject } from "@angular/core";
|
||||
import { Http } from "@angular/http";
|
||||
import { Observable } from "rxjs";
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
|
||||
import { SERVICE_CONFIG, IServiceConfig } from "../service.config";
|
||||
import { HTTP_JSON_OPTIONS, HTTP_GET_OPTIONS } from "../utils";
|
||||
@ -18,26 +19,24 @@ export abstract class ConfigurationService {
|
||||
* Get configurations.
|
||||
*
|
||||
* @abstract
|
||||
* returns {(Observable<Configuration> | Promise<Configuration> | Configuration)}
|
||||
* returns {(Observable<Configuration>)}
|
||||
*
|
||||
* @memberOf ConfigurationService
|
||||
*/
|
||||
abstract getConfigurations():
|
||||
| Observable<Configuration>
|
||||
| Promise<Configuration>
|
||||
| Configuration;
|
||||
| Observable<Configuration>;
|
||||
|
||||
/**
|
||||
* Save configurations.
|
||||
*
|
||||
* @abstract
|
||||
* returns {(Observable<Configuration> | Promise<Configuration> | Configuration)}
|
||||
* returns {(Observable<Configuration>)}
|
||||
*
|
||||
* @memberOf ConfigurationService
|
||||
*/
|
||||
abstract saveConfigurations(
|
||||
changedConfigs: any | { [key: string]: any | any[] }
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
@ -57,27 +56,23 @@ export class ConfigurationDefaultService extends ConfigurationService {
|
||||
}
|
||||
|
||||
getConfigurations():
|
||||
| Observable<Configuration>
|
||||
| Promise<Configuration>
|
||||
| Configuration {
|
||||
| Observable<Configuration> {
|
||||
return this.http
|
||||
.get(this._baseUrl, HTTP_GET_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.json() as Configuration)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json() as Configuration)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
saveConfigurations(
|
||||
changedConfigs: any | { [key: string]: any | any[] }
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!changedConfigs) {
|
||||
return Promise.reject("Bad argument!");
|
||||
return observableThrowError("Bad argument!");
|
||||
}
|
||||
|
||||
return this.http
|
||||
.put(this._baseUrl, JSON.stringify(changedConfigs), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(() => {})
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(() => { })
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Injectable, Inject } from "@angular/core";
|
||||
import { Http } from "@angular/http";
|
||||
import { Observable } from "rxjs";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../service.config";
|
||||
import {
|
||||
@ -10,6 +10,8 @@ import {
|
||||
} from "../utils";
|
||||
import { RequestQueryParams } from "./RequestQueryParams";
|
||||
import { Endpoint, ReplicationRule, Adapter } from "./interface";
|
||||
import { catchError, map } from "rxjs/operators";
|
||||
|
||||
|
||||
/**
|
||||
* Define the service methods to handle the endpoint related things.
|
||||
@ -33,7 +35,7 @@ export abstract class EndpointService {
|
||||
abstract getEndpoints(
|
||||
endpointName?: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Endpoint[]> | Promise<Endpoint[]> | Endpoint[];
|
||||
): Observable<Endpoint[]>;
|
||||
|
||||
/**
|
||||
* Get the specified endpoint.
|
||||
@ -46,14 +48,14 @@ export abstract class EndpointService {
|
||||
*/
|
||||
abstract getEndpoint(
|
||||
endpointId: number | string
|
||||
): Observable<Endpoint> | Promise<Endpoint> | Endpoint;
|
||||
): Observable<Endpoint>;
|
||||
|
||||
/**
|
||||
* Create new endpoint.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {Endpoint} endpoint
|
||||
* returns {(Observable<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
@ -70,7 +72,7 @@ export abstract class EndpointService {
|
||||
*/
|
||||
abstract createEndpoint(
|
||||
endpoint: Endpoint
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Update the specified endpoint.
|
||||
@ -78,51 +80,51 @@ export abstract class EndpointService {
|
||||
* @abstract
|
||||
* ** deprecated param {(number | string)} endpointId
|
||||
* ** deprecated param {Endpoint} endpoint
|
||||
* returns {(Observable<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
abstract updateEndpoint(
|
||||
endpointId: number | string,
|
||||
endpoint: Endpoint
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Delete the specified endpoint.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {(number | string)} endpointId
|
||||
* returns {(Observable<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
abstract deleteEndpoint(
|
||||
endpointId: number | string
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Ping the specified endpoint.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {Endpoint} endpoint
|
||||
* returns {(Observable<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
abstract pingEndpoint(
|
||||
endpoint: Endpoint
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Check endpoint whether in used with specific replication rule.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {{number | string}} endpointId
|
||||
* returns {{Observable<any> | any}}
|
||||
* returns {{Observable<any>}}
|
||||
*/
|
||||
abstract getEndpointWithReplicationRules(
|
||||
endpointId: number | string
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,7 +151,7 @@ export class EndpointDefaultService extends EndpointService {
|
||||
public getEndpoints(
|
||||
endpointName?: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Endpoint[]> | Promise<Endpoint[]> | Endpoint[] {
|
||||
): Observable<Endpoint[]> {
|
||||
if (!queryParams) {
|
||||
queryParams = new RequestQueryParams();
|
||||
}
|
||||
@ -159,23 +161,21 @@ export class EndpointDefaultService extends EndpointService {
|
||||
let requestUrl: string = `${this._endpointUrl}`;
|
||||
return this.http
|
||||
.get(requestUrl, buildHttpRequestOptions(queryParams))
|
||||
.toPromise()
|
||||
.then(response => response.json())
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json())
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getEndpoint(
|
||||
endpointId: number | string
|
||||
): Observable<Endpoint> | Promise<Endpoint> | Endpoint {
|
||||
): Observable<Endpoint> {
|
||||
if (!endpointId || endpointId <= 0) {
|
||||
return Promise.reject("Bad request argument.");
|
||||
return observableThrowError("Bad request argument.");
|
||||
}
|
||||
let requestUrl: string = `${this._endpointUrl}/${endpointId}`;
|
||||
return this.http
|
||||
.get(requestUrl, HTTP_GET_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.json() as Endpoint)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json() as Endpoint)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getAdapters(): Observable<any> | Promise<any> | any {
|
||||
@ -188,75 +188,70 @@ export class EndpointDefaultService extends EndpointService {
|
||||
|
||||
public createEndpoint(
|
||||
endpoint: Endpoint
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!endpoint) {
|
||||
return Promise.reject("Invalid endpoint.");
|
||||
return observableThrowError("Invalid endpoint.");
|
||||
}
|
||||
let requestUrl: string = `${this._endpointUrl}`;
|
||||
return this.http
|
||||
.post(requestUrl, JSON.stringify(endpoint), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public updateEndpoint(
|
||||
endpointId: number | string,
|
||||
endpoint: Endpoint
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!endpointId || endpointId <= 0) {
|
||||
return Promise.reject("Bad request argument.");
|
||||
return observableThrowError("Bad request argument.");
|
||||
}
|
||||
if (!endpoint) {
|
||||
return Promise.reject("Invalid endpoint.");
|
||||
return observableThrowError("Invalid endpoint.");
|
||||
}
|
||||
let requestUrl: string = `${this._endpointUrl}/${endpointId}`;
|
||||
return this.http
|
||||
.put(requestUrl, JSON.stringify(endpoint), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public deleteEndpoint(
|
||||
endpointId: number | string
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!endpointId || endpointId <= 0) {
|
||||
return Promise.reject("Bad request argument.");
|
||||
return observableThrowError("Bad request argument.");
|
||||
}
|
||||
let requestUrl: string = `${this._endpointUrl}/${endpointId}`;
|
||||
return this.http
|
||||
.delete(requestUrl)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public pingEndpoint(
|
||||
endpoint: Endpoint
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!endpoint) {
|
||||
return Promise.reject("Invalid endpoint.");
|
||||
return observableThrowError("Invalid endpoint.");
|
||||
}
|
||||
let requestUrl: string = `${this._endpointUrl}/ping`;
|
||||
return this.http
|
||||
.post(requestUrl, endpoint, HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getEndpointWithReplicationRules(
|
||||
endpointId: number | string
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!endpointId || endpointId <= 0) {
|
||||
return Promise.reject("Bad request argument.");
|
||||
return observableThrowError("Bad request argument.");
|
||||
}
|
||||
let requestUrl: string = `${this._endpointUrl}/${endpointId}/policies`;
|
||||
return this.http
|
||||
.get(requestUrl, HTTP_GET_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.json() as ReplicationRule[])
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json() as ReplicationRule[])
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { Observable } from "rxjs";
|
||||
import { Injectable, Inject } from "@angular/core";
|
||||
import { Http } from "@angular/http";
|
||||
import { SERVICE_CONFIG, IServiceConfig } from "../service.config";
|
||||
import { HTTP_GET_OPTIONS } from "../utils";
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
/**
|
||||
* Define the service methods to handle the job log related things.
|
||||
*
|
||||
@ -18,7 +18,7 @@ export abstract class JobLogService {
|
||||
* @abstract
|
||||
* ** deprecated param {string} jobType
|
||||
* ** deprecated param {(number | string)} jobId
|
||||
* returns {(Observable<string> | Promise<string> | string)}
|
||||
* returns {(Observable<string>)}
|
||||
* @memberof JobLogService
|
||||
*/
|
||||
|
||||
@ -26,7 +26,7 @@ export abstract class JobLogService {
|
||||
abstract getJobLog(
|
||||
jobType: string,
|
||||
jobId: number | string
|
||||
): Observable<string> | Promise<string> | string;
|
||||
): Observable<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,12 +56,11 @@ export class JobLogDefaultService extends JobLogService {
|
||||
this._supportedJobTypes = ["replication", "scan"];
|
||||
}
|
||||
|
||||
_getJobLog(logUrl: string): Observable<string> | Promise<string> | string {
|
||||
_getJobLog(logUrl: string): Observable<string> {
|
||||
return this.http
|
||||
.get(logUrl, HTTP_GET_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.text())
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.text())
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
_isSupportedJobType(jobType: string): boolean {
|
||||
@ -79,12 +78,12 @@ export class JobLogDefaultService extends JobLogService {
|
||||
public getJobLog(
|
||||
jobType: string,
|
||||
jobId: number | string
|
||||
): Observable<string> | Promise<string> | string {
|
||||
): Observable<string> {
|
||||
if (!this._isSupportedJobType(jobType)) {
|
||||
return Promise.reject("Unsupport job type: " + jobType);
|
||||
return observableThrowError("Unsupport job type: " + jobType);
|
||||
}
|
||||
if (!jobId || jobId <= 0) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
let logUrl: string = `${this._replicationJobBaseUrl}/${jobId}/log`;
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { Inject, Injectable } from "@angular/core";
|
||||
import { Http } from "@angular/http";
|
||||
import { Observable} from "rxjs";
|
||||
import { map, catchError} from "rxjs/operators";
|
||||
|
||||
import { RequestQueryParams } from "./RequestQueryParams";
|
||||
@ -9,18 +8,19 @@ import { Label } from "./interface";
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../service.config";
|
||||
import { buildHttpRequestOptions, HTTP_JSON_OPTIONS } from "../utils";
|
||||
import { extractJson } from "../shared/shared.utils";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
|
||||
export abstract class LabelService {
|
||||
abstract getGLabels(
|
||||
name?: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Label[]> | Promise<Label[]>;
|
||||
): Observable<Label[]>;
|
||||
|
||||
abstract getPLabels(
|
||||
projectId: number,
|
||||
name?: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Label[]> | Promise<Label[]>;
|
||||
): Observable<Label[]>;
|
||||
|
||||
abstract getProjectLabels(
|
||||
projectId: number,
|
||||
@ -37,16 +37,16 @@ export abstract class LabelService {
|
||||
|
||||
abstract createLabel(
|
||||
label: Label
|
||||
): Observable<Label> | Promise<Label> | Label;
|
||||
): Observable<Label>;
|
||||
|
||||
abstract getLabel(id: number): Observable<Label> | Promise<Label> | Label;
|
||||
abstract getLabel(id: number): Observable<Label>;
|
||||
|
||||
abstract updateLabel(
|
||||
id: number,
|
||||
param: Label
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
abstract deleteLabel(id: number): Observable<any> | Promise<any> | any;
|
||||
abstract deleteLabel(id: number): Observable<any>;
|
||||
|
||||
abstract getChartVersionLabels(
|
||||
projectName: string,
|
||||
@ -87,7 +87,7 @@ export class LabelDefaultService extends LabelService {
|
||||
getGLabels(
|
||||
name?: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Label[]> | Promise<Label[]> {
|
||||
): Observable<Label[]> {
|
||||
if (!queryParams) {
|
||||
queryParams = new RequestQueryParams();
|
||||
}
|
||||
@ -98,16 +98,15 @@ export class LabelDefaultService extends LabelService {
|
||||
}
|
||||
return this.http
|
||||
.get(this.labelUrl, buildHttpRequestOptions(queryParams))
|
||||
.toPromise()
|
||||
.then(response => response.json())
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json())
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
getPLabels(
|
||||
projectId: number,
|
||||
name?: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Label[]> | Promise<Label[]> {
|
||||
): Observable<Label[]> {
|
||||
if (!queryParams) {
|
||||
queryParams = new RequestQueryParams();
|
||||
}
|
||||
@ -120,9 +119,8 @@ export class LabelDefaultService extends LabelService {
|
||||
}
|
||||
return this.http
|
||||
.get(this.labelUrl, buildHttpRequestOptions(queryParams))
|
||||
.toPromise()
|
||||
.then(response => response.json())
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json())
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
getProjectLabels(
|
||||
@ -165,57 +163,53 @@ export class LabelDefaultService extends LabelService {
|
||||
return this.http
|
||||
.get(this.labelUrl, buildHttpRequestOptions(queryParams))
|
||||
.pipe(map(response => response.json()))
|
||||
.pipe(catchError(error => Promise.reject(error)));
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
createLabel(label: Label): Observable<any> | Promise<any> | any {
|
||||
createLabel(label: Label): Observable<any> {
|
||||
if (!label) {
|
||||
return Promise.reject("Invalid label.");
|
||||
return observableThrowError("Invalid label.");
|
||||
}
|
||||
return this.http
|
||||
.post(this.labelUrl, JSON.stringify(label), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
getLabel(id: number): Observable<Label> | Promise<Label> | Label {
|
||||
getLabel(id: number): Observable<Label> {
|
||||
if (!id || id <= 0) {
|
||||
return Promise.reject("Bad request argument.");
|
||||
return observableThrowError("Bad request argument.");
|
||||
}
|
||||
let reqUrl = `${this.labelUrl}/${id}`;
|
||||
return this.http
|
||||
.get(reqUrl, HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.json())
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json())
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
updateLabel(id: number, label: Label): Observable<any> | Promise<any> | any {
|
||||
updateLabel(id: number, label: Label): Observable<any> {
|
||||
if (!id || id <= 0) {
|
||||
return Promise.reject("Bad request argument.");
|
||||
return observableThrowError("Bad request argument.");
|
||||
}
|
||||
if (!label) {
|
||||
return Promise.reject("Invalid endpoint.");
|
||||
return observableThrowError("Invalid endpoint.");
|
||||
}
|
||||
let reqUrl = `${this.labelUrl}/${id}`;
|
||||
return this.http
|
||||
.put(reqUrl, JSON.stringify(label), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
deleteLabel(id: number): Observable<any> | Promise<any> | any {
|
||||
deleteLabel(id: number): Observable<any> {
|
||||
if (!id || id <= 0) {
|
||||
return Promise.reject("Bad request argument.");
|
||||
return observableThrowError("Bad request argument.");
|
||||
}
|
||||
let reqUrl = `${this.labelUrl}/${id}`;
|
||||
return this.http
|
||||
.delete(reqUrl)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
getChartVersionLabels(
|
||||
|
@ -27,13 +27,13 @@ export abstract class ProjectService {
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {string|number} [projectId]
|
||||
* returns {(Observable<Project> | Promise<Project> | Project)}
|
||||
* returns {(Observable<Project> )}
|
||||
*
|
||||
* @memberOf ProjectService
|
||||
*/
|
||||
abstract getProject(
|
||||
projectId: number | string
|
||||
): Observable<Project> | Promise<Project> | Project;
|
||||
): Observable<Project> ;
|
||||
|
||||
/**
|
||||
* Update the specified project.
|
||||
@ -41,14 +41,14 @@ export abstract class ProjectService {
|
||||
* @abstract
|
||||
* ** deprecated param {(number | string)} projectId
|
||||
* ** deprecated param {ProjectPolicy} projectPolicy
|
||||
* returns {(Observable<any> | Promise<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
abstract updateProjectPolicy(
|
||||
projectId: number | string,
|
||||
projectPolicy: ProjectPolicy
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Get all projects
|
||||
@ -58,7 +58,7 @@ export abstract class ProjectService {
|
||||
* ** deprecated param {number} isPublic
|
||||
* ** deprecated param {number} page
|
||||
* ** deprecated param {number} pageSize
|
||||
* returns {(Observable<any> | Promise<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf EndpointService
|
||||
*/
|
||||
@ -67,7 +67,7 @@ export abstract class ProjectService {
|
||||
isPublic: number,
|
||||
page?: number,
|
||||
pageSize?: number
|
||||
): Observable<Project[]> | Promise<Project[]> | Project[];
|
||||
): Observable<Project[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,9 +88,9 @@ export class ProjectDefaultService extends ProjectService {
|
||||
|
||||
public getProject(
|
||||
projectId: number | string
|
||||
): Observable<Project> | Promise<Project> | Project {
|
||||
): Observable<Project> {
|
||||
if (!projectId) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
let baseUrl: string = this.config.projectBaseEndpoint
|
||||
? this.config.projectBaseEndpoint
|
||||
@ -106,7 +106,7 @@ export class ProjectDefaultService extends ProjectService {
|
||||
isPublic: number,
|
||||
page?: number,
|
||||
pageSize?: number
|
||||
): Observable<Project[]> | Promise<Project[]> | Project[] {
|
||||
): Observable<Project[]> {
|
||||
let baseUrl: string = this.config.projectBaseEndpoint
|
||||
? this.config.projectBaseEndpoint
|
||||
: "/api/projects";
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { Http } from "@angular/http";
|
||||
import { Injectable, Inject } from "@angular/core";
|
||||
|
||||
import { SERVICE_CONFIG, IServiceConfig } from "../service.config";
|
||||
import {
|
||||
buildHttpRequestOptions,
|
||||
@ -34,7 +33,7 @@ export abstract class ReplicationService {
|
||||
* ** deprecated param {(number | string)} [projectId]
|
||||
* ** deprecated param {string} [ruleName]
|
||||
* ** deprecated param {RequestQueryParams} [queryParams]
|
||||
* returns {(Observable<ReplicationRule[]> | Promise<ReplicationRule[]> | ReplicationRule[])}
|
||||
* returns {(Observable<ReplicationRule[]>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
@ -43,22 +42,20 @@ export abstract class ReplicationService {
|
||||
ruleName?: string,
|
||||
queryParams?: RequestQueryParams
|
||||
):
|
||||
| Observable<ReplicationRule[]>
|
||||
| Promise<ReplicationRule[]>
|
||||
| ReplicationRule[];
|
||||
| Observable<ReplicationRule[]>;
|
||||
|
||||
/**
|
||||
* Get the specified replication rule.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {(number | string)} ruleId
|
||||
* returns {(Observable<ReplicationRule> | Promise<ReplicationRule> | ReplicationRule)}
|
||||
* returns {(Observable<ReplicationRule>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
abstract getReplicationRule(
|
||||
ruleId: number | string
|
||||
): Observable<ReplicationRule> | Promise<ReplicationRule> | ReplicationRule;
|
||||
): Observable<ReplicationRule>;
|
||||
|
||||
|
||||
/**
|
||||
@ -77,71 +74,71 @@ export abstract class ReplicationService {
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {ReplicationRule} replicationRule
|
||||
* returns {(Observable<any> | Promise<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
abstract createReplicationRule(
|
||||
replicationRule: ReplicationRule
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Update the specified replication rule.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {ReplicationRule} replicationRule
|
||||
* returns {(Observable<any> | Promise<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
abstract updateReplicationRule(
|
||||
id: number,
|
||||
rep: ReplicationRule
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Delete the specified replication rule.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {(number | string)} ruleId
|
||||
* returns {(Observable<any> | Promise<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
abstract deleteReplicationRule(
|
||||
ruleId: number | string
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Enable the specified replication rule.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {(number | string)} ruleId
|
||||
* returns {(Observable<any> | Promise<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
abstract enableReplicationRule(
|
||||
ruleId: number | string,
|
||||
enablement: number
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Disable the specified replication rule.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {(number | string)} ruleId
|
||||
* returns {(Observable<any> | Promise<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
abstract disableReplicationRule(
|
||||
ruleId: number | string
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
abstract replicateRule(
|
||||
ruleId: number | string
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Get the jobs for the specified replication rule.
|
||||
@ -155,26 +152,26 @@ export abstract class ReplicationService {
|
||||
* @abstract
|
||||
* ** deprecated param {(number | string)} ruleId
|
||||
* ** deprecated param {RequestQueryParams} [queryParams]
|
||||
* returns {(Observable<ReplicationJob> | Promise<ReplicationJob> | ReplicationJob)}
|
||||
* returns {(Observable<ReplicationJob>)}
|
||||
*
|
||||
* @memberOf ReplicationService
|
||||
*/
|
||||
abstract getExecutions(
|
||||
ruleId: number | string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<ReplicationJob> | Promise<ReplicationJob> | ReplicationJob;
|
||||
): Observable<ReplicationJob>;
|
||||
|
||||
/**
|
||||
* Get the log of the specified job.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {(number | string)} jobId
|
||||
* returns {(Observable<string> | Promise<string> | string)}
|
||||
* returns {(Observable<string>)}
|
||||
* @memberof ReplicationService
|
||||
*/
|
||||
abstract getJobLog(
|
||||
jobId: number | string
|
||||
): Observable<string> | Promise<string> | string;
|
||||
): Observable<string>;
|
||||
|
||||
abstract stopJobs(
|
||||
jobId: number | string
|
||||
@ -217,7 +214,7 @@ export class ReplicationDefaultService extends ReplicationService {
|
||||
rule.name !== undefined &&
|
||||
rule.name.trim() !== "" &&
|
||||
rule.src_namespaces && rule.src_namespaces.length > 0 &&
|
||||
(!!rule.dest_registry_id || !! rule.src_registry_id)
|
||||
(!!rule.dest_registry_id || !!rule.src_registry_id)
|
||||
);
|
||||
}
|
||||
|
||||
@ -230,9 +227,7 @@ export class ReplicationDefaultService extends ReplicationService {
|
||||
ruleName?: string,
|
||||
queryParams?: RequestQueryParams
|
||||
):
|
||||
| Observable<ReplicationRule[]>
|
||||
| Promise<ReplicationRule[]>
|
||||
| ReplicationRule[] {
|
||||
| Observable<ReplicationRule[]> {
|
||||
if (!queryParams) {
|
||||
queryParams = new RequestQueryParams();
|
||||
}
|
||||
@ -247,24 +242,22 @@ export class ReplicationDefaultService extends ReplicationService {
|
||||
|
||||
return this.http
|
||||
.get(this._ruleBaseUrl, buildHttpRequestOptions(queryParams))
|
||||
.toPromise()
|
||||
.then(response => response.json() as ReplicationRule[])
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json() as ReplicationRule[])
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getReplicationRule(
|
||||
ruleId: number | string
|
||||
): Observable<ReplicationRule> | Promise<ReplicationRule> | ReplicationRule {
|
||||
): Observable<ReplicationRule> {
|
||||
if (!ruleId) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
let url: string = `${this._ruleBaseUrl}/${ruleId}`;
|
||||
return this.http
|
||||
.get(url, HTTP_GET_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.json() as ReplicationRule)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json() as ReplicationRule)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getReplicationTasks(
|
||||
@ -275,16 +268,16 @@ export class ReplicationDefaultService extends ReplicationService {
|
||||
}
|
||||
let url: string = `${this._replicateUrl}/${executionId}/tasks`;
|
||||
return this.http
|
||||
.get(url, HTTP_GET_OPTIONS)
|
||||
.pipe(map (response => response.json() as ReplicationTasks)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
.get(url, HTTP_GET_OPTIONS)
|
||||
.pipe(map(response => response.json() as ReplicationTasks)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public createReplicationRule(
|
||||
replicationRule: ReplicationRule
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!this._isValidRule(replicationRule)) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
return this.http
|
||||
@ -293,94 +286,88 @@ export class ReplicationDefaultService extends ReplicationService {
|
||||
JSON.stringify(replicationRule),
|
||||
HTTP_JSON_OPTIONS
|
||||
)
|
||||
.toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public updateReplicationRule(
|
||||
id: number,
|
||||
rep: ReplicationRule
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!this._isValidRule(rep)) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
let url = `${this._ruleBaseUrl}/${id}`;
|
||||
return this.http
|
||||
.put(url, JSON.stringify(rep), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public deleteReplicationRule(
|
||||
ruleId: number | string
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!ruleId || ruleId <= 0) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
let url: string = `${this._ruleBaseUrl}/${ruleId}`;
|
||||
return this.http
|
||||
.delete(url, HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public replicateRule(
|
||||
ruleId: number | string
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!ruleId) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
let url: string = `${this._replicateUrl}`;
|
||||
return this.http
|
||||
.post(url, { policy_id: ruleId }, HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public enableReplicationRule(
|
||||
ruleId: number | string,
|
||||
enablement: number
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!ruleId || ruleId <= 0) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
let url: string = `${this._ruleBaseUrl}/${ruleId}/enablement`;
|
||||
return this.http
|
||||
.put(url, { enabled: enablement }, HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public disableReplicationRule(
|
||||
ruleId: number | string
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!ruleId || ruleId <= 0) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
let url: string = `${this._ruleBaseUrl}/${ruleId}/enablement`;
|
||||
return this.http
|
||||
.put(url, { enabled: 0 }, HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getExecutions(
|
||||
ruleId: number | string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<ReplicationJob> | Promise<ReplicationJob> | ReplicationJob {
|
||||
): Observable<ReplicationJob> {
|
||||
if (!ruleId || ruleId <= 0) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
if (!queryParams) {
|
||||
@ -390,8 +377,7 @@ export class ReplicationDefaultService extends ReplicationService {
|
||||
queryParams.set("policy_id", "" + ruleId);
|
||||
return this.http
|
||||
.get(this._replicateUrl, buildHttpRequestOptions(queryParams))
|
||||
.toPromise()
|
||||
.then(response => {
|
||||
.pipe(map(response => {
|
||||
let result: ReplicationJob = {
|
||||
metadata: {
|
||||
xTotalCount: 0
|
||||
@ -414,37 +400,37 @@ export class ReplicationDefaultService extends ReplicationService {
|
||||
|
||||
return result;
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getJobLog(
|
||||
jobId: number | string
|
||||
): Observable<string> | Promise<string> | string {
|
||||
): Observable<string> {
|
||||
if (!jobId || jobId <= 0) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
let logUrl = `${this._replicateUrl}/${jobId}/log`;
|
||||
return this.http
|
||||
.get(logUrl, HTTP_GET_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.text())
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.text())
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public stopJobs(
|
||||
jobId: number | string
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!jobId || jobId <= 0) {
|
||||
return observableThrowError("Bad request argument.");
|
||||
}
|
||||
let requestUrl: string = `${this._replicateUrl}/${jobId}`;
|
||||
|
||||
return this.http
|
||||
.put(
|
||||
requestUrl,
|
||||
HTTP_JSON_OPTIONS
|
||||
)
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { Observable } from "rxjs";
|
||||
import { RequestQueryParams } from './RequestQueryParams';
|
||||
import { Repository, RepositoryItem } from './interface';
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
@ -6,6 +5,8 @@ import { Injectable, Inject } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../service.config';
|
||||
import { buildHttpRequestOptions, HTTP_JSON_OPTIONS } from '../utils';
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
|
||||
/**
|
||||
* Define service methods for handling the repository related things.
|
||||
@ -27,12 +28,12 @@ export abstract class RepositoryService {
|
||||
* ** deprecated param {(number | string)} projectId
|
||||
* ** deprecated param {string} repositoryName
|
||||
* ** deprecated param {RequestQueryParams} [queryParams]
|
||||
* returns {(Observable<Repository> | Promise<Repository> | Repository)}
|
||||
* returns {(Observable<Repository>)}
|
||||
*
|
||||
* @memberOf RepositoryService
|
||||
*/
|
||||
abstract getRepositories(projectId: number | string, repositoryName?: string, queryParams?: RequestQueryParams):
|
||||
Observable<Repository> | Promise<Repository> | Repository;
|
||||
Observable<Repository>;
|
||||
|
||||
/**
|
||||
* Update description of specified repository.
|
||||
@ -40,22 +41,22 @@ export abstract class RepositoryService {
|
||||
* @abstract
|
||||
* ** deprecated param {number | string} projectId
|
||||
* ** deprecated param {string} repoName
|
||||
* returns {(Observable<Repository> | Promise<Repository> | Repository)}
|
||||
* returns {(Observable<Repository>)}
|
||||
*
|
||||
* @memberOf RepositoryService
|
||||
*/
|
||||
abstract updateRepositoryDescription(repoName: string, description: string): Observable<any> | Promise<any> | any;
|
||||
abstract updateRepositoryDescription(repoName: string, description: string): Observable<any>;
|
||||
|
||||
/**
|
||||
* DELETE the specified repository.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {string} repositoryName
|
||||
* returns {(Observable<any> | Promise<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf RepositoryService
|
||||
*/
|
||||
abstract deleteRepository(repositoryName: string): Observable<any> | Promise<any> | any;
|
||||
abstract deleteRepository(repositoryName: string): Observable<any>;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,9 +76,9 @@ export class RepositoryDefaultService extends RepositoryService {
|
||||
}
|
||||
|
||||
public getRepositories(projectId: number | string, repositoryName?: string, queryParams?: RequestQueryParams):
|
||||
Observable<Repository> | Promise<Repository> | Repository {
|
||||
Observable<Repository> {
|
||||
if (!projectId) {
|
||||
return Promise.reject('Bad argument');
|
||||
return observableThrowError('Bad argument');
|
||||
}
|
||||
|
||||
if (!queryParams) {
|
||||
@ -90,8 +91,8 @@ export class RepositoryDefaultService extends RepositoryService {
|
||||
}
|
||||
|
||||
let url: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : '/api/repositories';
|
||||
return this.http.get(url, buildHttpRequestOptions(queryParams)).toPromise()
|
||||
.then(response => {
|
||||
return this.http.get(url, buildHttpRequestOptions(queryParams))
|
||||
.pipe(map(response => {
|
||||
let result: Repository = {
|
||||
metadata: { xTotalCount: 0 },
|
||||
data: []
|
||||
@ -114,11 +115,11 @@ export class RepositoryDefaultService extends RepositoryService {
|
||||
|
||||
return result;
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public updateRepositoryDescription(repositoryName: string, description: string,
|
||||
queryParams?: RequestQueryParams): Observable<any> | Promise<any> | any {
|
||||
queryParams?: RequestQueryParams): Observable<any> {
|
||||
|
||||
if (!queryParams) {
|
||||
queryParams = new RequestQueryParams();
|
||||
@ -126,20 +127,20 @@ export class RepositoryDefaultService extends RepositoryService {
|
||||
|
||||
let baseUrl: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : '/api/repositories';
|
||||
let url = `${baseUrl}/${repositoryName}`;
|
||||
return this.http.put(url, {'description': description }, HTTP_JSON_OPTIONS).toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => Promise.reject(error));
|
||||
return this.http.put(url, {'description': description }, HTTP_JSON_OPTIONS)
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public deleteRepository(repositoryName: string): Observable<any> | Promise<any> | any {
|
||||
public deleteRepository(repositoryName: string): Observable<any> {
|
||||
if (!repositoryName) {
|
||||
return Promise.reject('Bad argument');
|
||||
return observableThrowError('Bad argument');
|
||||
}
|
||||
let url: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : '/api/repositories';
|
||||
url = `${url}/${repositoryName}`;
|
||||
|
||||
return this.http.delete(url, HTTP_JSON_OPTIONS).toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => {return Promise.reject(error); });
|
||||
return this.http.delete(url, HTTP_JSON_OPTIONS)
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { Observable} from "rxjs";
|
||||
import { Label } from "./interface";
|
||||
import { Inject, Injectable } from "@angular/core";
|
||||
import { Http } from "@angular/http";
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../service.config";
|
||||
import { buildHttpRequestOptions, HTTP_JSON_OPTIONS } from "../utils";
|
||||
import { RequestQueryParams } from "./RequestQueryParams";
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
|
||||
export abstract class LabelService {
|
||||
abstract getLabels(
|
||||
@ -16,16 +17,16 @@ export abstract class LabelService {
|
||||
|
||||
abstract createLabel(
|
||||
label: Label
|
||||
): Observable<Label> | Promise<Label> | Label;
|
||||
): Observable<Label>;
|
||||
|
||||
abstract getLabel(id: number): Observable<Label> | Promise<Label> | Label;
|
||||
abstract getLabel(id: number): Observable<Label>;
|
||||
|
||||
abstract updateLabel(
|
||||
id: number,
|
||||
param: Label
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
abstract deleteLabel(id: number): Observable<any> | Promise<any> | any;
|
||||
abstract deleteLabel(id: number): Observable<any>;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
@ -47,7 +48,7 @@ export class LabelDefaultService extends LabelService {
|
||||
projectId?: number,
|
||||
name?: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Label[]> | Promise<Label[]> {
|
||||
): Observable<Label[]> {
|
||||
if (!queryParams) {
|
||||
queryParams = new RequestQueryParams();
|
||||
}
|
||||
@ -62,15 +63,14 @@ export class LabelDefaultService extends LabelService {
|
||||
}
|
||||
return this.http
|
||||
.get(this._labelUrl, buildHttpRequestOptions(queryParams))
|
||||
.toPromise()
|
||||
.then(response => response.json())
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json())
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
getGLabels(
|
||||
name?: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Label[]> | Promise<Label[]> {
|
||||
): Observable<Label[]> {
|
||||
if (!queryParams) {
|
||||
queryParams = new RequestQueryParams();
|
||||
}
|
||||
@ -81,16 +81,15 @@ export class LabelDefaultService extends LabelService {
|
||||
}
|
||||
return this.http
|
||||
.get(this._labelUrl, buildHttpRequestOptions(queryParams))
|
||||
.toPromise()
|
||||
.then(response => response.json())
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json())
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
getPLabels(
|
||||
projectId: number,
|
||||
name?: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Label[]> | Promise<Label[]> {
|
||||
): Observable<Label[]> {
|
||||
if (!queryParams) {
|
||||
queryParams = new RequestQueryParams();
|
||||
}
|
||||
@ -103,57 +102,52 @@ export class LabelDefaultService extends LabelService {
|
||||
}
|
||||
return this.http
|
||||
.get(this._labelUrl, buildHttpRequestOptions(queryParams))
|
||||
.toPromise()
|
||||
.then(response => response.json())
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json())
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
createLabel(label: Label): Observable<any> | Promise<any> | any {
|
||||
createLabel(label: Label): Observable<any> {
|
||||
if (!label) {
|
||||
return Promise.reject("Invalid label.");
|
||||
return observableThrowError("Invalid label.");
|
||||
}
|
||||
return this.http
|
||||
.post(this._labelUrl, JSON.stringify(label), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
getLabel(id: number): Observable<Label> | Promise<Label> | Label {
|
||||
getLabel(id: number): Observable<Label> {
|
||||
if (!id || id <= 0) {
|
||||
return Promise.reject("Bad request argument.");
|
||||
return observableThrowError("Bad request argument.");
|
||||
}
|
||||
let reqUrl = `${this._labelUrl}/${id}`;
|
||||
return this.http
|
||||
.get(reqUrl)
|
||||
.toPromise()
|
||||
.then(response => response.json())
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json())
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
updateLabel(id: number, label: Label): Observable<any> | Promise<any> | any {
|
||||
updateLabel(id: number, label: Label): Observable<any> {
|
||||
if (!id || id <= 0) {
|
||||
return Promise.reject("Bad request argument.");
|
||||
return observableThrowError("Bad request argument.");
|
||||
}
|
||||
if (!label) {
|
||||
return Promise.reject("Invalid endpoint.");
|
||||
return observableThrowError("Invalid endpoint.");
|
||||
}
|
||||
let reqUrl = `${this._labelUrl}/${id}`;
|
||||
return this.http
|
||||
.put(reqUrl, JSON.stringify(label), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
deleteLabel(id: number): Observable<any> | Promise<any> | any {
|
||||
deleteLabel(id: number): Observable<any> {
|
||||
if (!id || id <= 0) {
|
||||
return Promise.reject("Bad request argument.");
|
||||
return observableThrowError("Bad request argument.");
|
||||
}
|
||||
let reqUrl = `${this._labelUrl}/${id}`;
|
||||
return this.http
|
||||
.delete(reqUrl)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { Http } from "@angular/http";
|
||||
import { Injectable, Inject } from "@angular/core";
|
||||
import { Observable, of } from "rxjs";
|
||||
|
||||
import { SERVICE_CONFIG, IServiceConfig } from "../service.config";
|
||||
import { buildHttpRequestOptions, HTTP_JSON_OPTIONS } from "../utils";
|
||||
import { RequestQueryParams } from "./RequestQueryParams";
|
||||
import { VulnerabilityItem, VulnerabilitySummary } from "./interface";
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, of, throwError as observableThrowError } from "rxjs";
|
||||
|
||||
/**
|
||||
* Get the vulnerabilities scanning results for the specified tag.
|
||||
@ -20,7 +21,7 @@ export abstract class ScanningResultService {
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {string} tagId
|
||||
* returns {(Observable<VulnerabilitySummary> | Promise<VulnerabilitySummary> | VulnerabilitySummary)}
|
||||
* returns {(Observable<VulnerabilitySummary>)}
|
||||
*
|
||||
* @memberOf ScanningResultService
|
||||
*/
|
||||
@ -29,16 +30,14 @@ export abstract class ScanningResultService {
|
||||
tagId: string,
|
||||
queryParams?: RequestQueryParams
|
||||
):
|
||||
| Observable<VulnerabilitySummary>
|
||||
| Promise<VulnerabilitySummary>
|
||||
| VulnerabilitySummary;
|
||||
| Observable<VulnerabilitySummary>;
|
||||
|
||||
/**
|
||||
* Get the detailed vulnerabilities scanning results.
|
||||
*
|
||||
* @abstract
|
||||
* ** deprecated param {string} tagId
|
||||
* returns {(Observable<VulnerabilityItem[]> | Promise<VulnerabilityItem[]> | VulnerabilityItem[])}
|
||||
* returns {(Observable<VulnerabilityItem[]>)}
|
||||
*
|
||||
* @memberOf ScanningResultService
|
||||
*/
|
||||
@ -47,9 +46,7 @@ export abstract class ScanningResultService {
|
||||
tagId: string,
|
||||
queryParams?: RequestQueryParams
|
||||
):
|
||||
| Observable<VulnerabilityItem[]>
|
||||
| Promise<VulnerabilityItem[]>
|
||||
| VulnerabilityItem[];
|
||||
| Observable<VulnerabilityItem[]>;
|
||||
|
||||
/**
|
||||
* Start a new vulnerability scanning
|
||||
@ -57,24 +54,24 @@ export abstract class ScanningResultService {
|
||||
* @abstract
|
||||
* ** deprecated param {string} repoName
|
||||
* ** deprecated param {string} tagId
|
||||
* returns {(Observable<any> | Promise<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ScanningResultService
|
||||
*/
|
||||
abstract startVulnerabilityScanning(
|
||||
repoName: string,
|
||||
tagId: string
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Trigger the scanning all action.
|
||||
*
|
||||
* @abstract
|
||||
* returns {(Observable<any> | Promise<any> | any)}
|
||||
* returns {(Observable<any>)}
|
||||
*
|
||||
* @memberOf ScanningResultService
|
||||
*/
|
||||
abstract startScanningAll(): Observable<any> | Promise<any> | any;
|
||||
abstract startScanningAll(): Observable<any>;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
@ -96,11 +93,9 @@ export class ScanningResultDefaultService extends ScanningResultService {
|
||||
tagId: string,
|
||||
queryParams?: RequestQueryParams
|
||||
):
|
||||
| Observable<VulnerabilitySummary>
|
||||
| Promise<VulnerabilitySummary>
|
||||
| VulnerabilitySummary {
|
||||
| Observable<VulnerabilitySummary> {
|
||||
if (!repoName || repoName.trim() === "" || !tagId || tagId.trim() === "") {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
return of({} as VulnerabilitySummary);
|
||||
@ -111,11 +106,9 @@ export class ScanningResultDefaultService extends ScanningResultService {
|
||||
tagId: string,
|
||||
queryParams?: RequestQueryParams
|
||||
):
|
||||
| Observable<VulnerabilityItem[]>
|
||||
| Promise<VulnerabilityItem[]>
|
||||
| VulnerabilityItem[] {
|
||||
| Observable<VulnerabilityItem[]> {
|
||||
if (!repoName || repoName.trim() === "" || !tagId || tagId.trim() === "") {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
return this.http
|
||||
@ -123,17 +116,16 @@ export class ScanningResultDefaultService extends ScanningResultService {
|
||||
`${this._baseUrl}/${repoName}/tags/${tagId}/vulnerability/details`,
|
||||
buildHttpRequestOptions(queryParams)
|
||||
)
|
||||
.toPromise()
|
||||
.then(response => response.json() as VulnerabilityItem[])
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json() as VulnerabilityItem[])
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
startVulnerabilityScanning(
|
||||
repoName: string,
|
||||
tagId: string
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!repoName || repoName.trim() === "" || !tagId || tagId.trim() === "") {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
return this.http
|
||||
@ -141,20 +133,18 @@ export class ScanningResultDefaultService extends ScanningResultService {
|
||||
`${this._baseUrl}/${repoName}/tags/${tagId}/scan`,
|
||||
HTTP_JSON_OPTIONS
|
||||
)
|
||||
.toPromise()
|
||||
.then(() => {
|
||||
.pipe(map(() => {
|
||||
return true;
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
startScanningAll(): Observable<any> | Promise<any> | any {
|
||||
startScanningAll(): Observable<any> {
|
||||
return this.http
|
||||
.post(`${this._baseUrl}/scanAll`, HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(() => {
|
||||
.pipe(map(() => {
|
||||
return true;
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
import { Observable } from "rxjs";
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
import { SystemInfo } from './interface';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../service.config';
|
||||
import {HTTP_GET_OPTIONS} from "../utils";
|
||||
|
||||
/**
|
||||
* Get System information about current backend server.
|
||||
* @abstract
|
||||
@ -15,7 +17,7 @@ export abstract class SystemInfoService {
|
||||
* @abstract
|
||||
* returns
|
||||
*/
|
||||
abstract getSystemInfo(): Observable<SystemInfo> | Promise<SystemInfo> | SystemInfo;
|
||||
abstract getSystemInfo(): Observable<SystemInfo>;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
@ -25,12 +27,11 @@ export class SystemInfoDefaultService extends SystemInfoService {
|
||||
private http: Http) {
|
||||
super();
|
||||
}
|
||||
getSystemInfo(): Observable<SystemInfo> | Promise<SystemInfo> | SystemInfo {
|
||||
getSystemInfo(): Observable<SystemInfo> {
|
||||
let url = this.config.systemInfoEndpoint ? this.config.systemInfoEndpoint : '/api/systeminfo';
|
||||
return this.http.get(url, HTTP_GET_OPTIONS)
|
||||
.toPromise()
|
||||
.then(systemInfo => systemInfo.json() as SystemInfo)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(systemInfo => systemInfo.json() as SystemInfo)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { Injectable, Inject } from "@angular/core";
|
||||
import { Http } from "@angular/http";
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
import { SERVICE_CONFIG, IServiceConfig } from "../service.config";
|
||||
import {
|
||||
@ -10,6 +9,8 @@ import {
|
||||
} from "../utils";
|
||||
import { RequestQueryParams } from "./RequestQueryParams";
|
||||
import { Tag, Manifest } from "./interface";
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
|
||||
/**
|
||||
* For getting tag signatures.
|
||||
@ -40,14 +41,14 @@ export abstract class TagService {
|
||||
* @abstract
|
||||
* ** deprecated param {string} repositoryName
|
||||
* ** deprecated param {RequestQueryParams} [queryParams]
|
||||
* returns {(Observable<Tag[]> | Promise<Tag[]> | Tag[])}
|
||||
* returns {(Observable<Tag[]>)}
|
||||
*
|
||||
* @memberOf TagService
|
||||
*/
|
||||
abstract getTags(
|
||||
repositoryName: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Tag[]> | Promise<Tag[]> | Tag[];
|
||||
): Observable<Tag[]>;
|
||||
|
||||
/**
|
||||
* Delete the specified tag.
|
||||
@ -62,7 +63,7 @@ export abstract class TagService {
|
||||
abstract deleteTag(
|
||||
repositoryName: string,
|
||||
tag: string
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Get the specified tag.
|
||||
@ -70,7 +71,7 @@ export abstract class TagService {
|
||||
* @abstract
|
||||
* ** deprecated param {string} repositoryName
|
||||
* ** deprecated param {string} tag
|
||||
* returns {(Observable<Tag> | Promise<Tag> | Tag)}
|
||||
* returns {(Observable<Tag>)}
|
||||
*
|
||||
* @memberOf TagService
|
||||
*/
|
||||
@ -78,31 +79,31 @@ export abstract class TagService {
|
||||
repositoryName: string,
|
||||
tag: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Tag> | Promise<Tag> | Tag;
|
||||
): Observable<Tag>;
|
||||
|
||||
abstract addLabelToImages(
|
||||
repoName: string,
|
||||
tagName: string,
|
||||
labelId: number
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
abstract deleteLabelToImages(
|
||||
repoName: string,
|
||||
tagName: string,
|
||||
labelId: number
|
||||
): Observable<any> | Promise<any> | any;
|
||||
): Observable<any>;
|
||||
|
||||
/**
|
||||
* Get manifest of tag under the specified repository.
|
||||
*
|
||||
* @abstract
|
||||
* returns {(Observable<Manifest> | Promise<Manifest> | Manifest)}
|
||||
* returns {(Observable<Manifest>)}
|
||||
*
|
||||
* @memberOf TagService
|
||||
*/
|
||||
abstract getManifest(
|
||||
repositoryName: string,
|
||||
tag: string
|
||||
): Observable<Manifest> | Promise<Manifest> | Manifest;
|
||||
): Observable<Manifest>;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,7 +135,7 @@ export class TagDefaultService extends TagService {
|
||||
_getTags(
|
||||
repositoryName: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Promise<Tag[]> {
|
||||
): Observable<Tag[]> {
|
||||
if (!queryParams) {
|
||||
queryParams = new RequestQueryParams();
|
||||
}
|
||||
@ -144,26 +145,24 @@ export class TagDefaultService extends TagService {
|
||||
|
||||
return this.http
|
||||
.get(url, buildHttpRequestOptions(queryParams))
|
||||
.toPromise()
|
||||
.then(response => response.json() as Tag[])
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json() as Tag[])
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
_getSignatures(repositoryName: string): Promise<VerifiedSignature[]> {
|
||||
_getSignatures(repositoryName: string): Observable<VerifiedSignature[]> {
|
||||
let url: string = `${this._baseUrl}/${repositoryName}/signatures`;
|
||||
return this.http
|
||||
.get(url, HTTP_GET_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.json() as VerifiedSignature[])
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json() as VerifiedSignature[])
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getTags(
|
||||
repositoryName: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Tag[]> | Promise<Tag[]> | Tag[] {
|
||||
): Observable<Tag[]> {
|
||||
if (!repositoryName) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
return this._getTags(repositoryName, queryParams);
|
||||
}
|
||||
@ -171,43 +170,41 @@ export class TagDefaultService extends TagService {
|
||||
public deleteTag(
|
||||
repositoryName: string,
|
||||
tag: string
|
||||
): Observable<any> | Promise<Tag> | any {
|
||||
): Observable<any> {
|
||||
if (!repositoryName || !tag) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
let url: string = `${this._baseUrl}/${repositoryName}/tags/${tag}`;
|
||||
return this.http
|
||||
.delete(url, HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getTag(
|
||||
repositoryName: string,
|
||||
tag: string,
|
||||
queryParams?: RequestQueryParams
|
||||
): Observable<Tag> | Promise<Tag> | Tag {
|
||||
): Observable<Tag> {
|
||||
if (!repositoryName || !tag) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
|
||||
let url: string = `${this._baseUrl}/${repositoryName}/tags/${tag}`;
|
||||
return this.http
|
||||
.get(url, HTTP_GET_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.json() as Tag)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json() as Tag)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public addLabelToImages(
|
||||
repoName: string,
|
||||
tagName: string,
|
||||
labelId: number
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!labelId || !tagName || !repoName) {
|
||||
return Promise.reject("Invalid parameters.");
|
||||
return observableThrowError("Invalid parameters.");
|
||||
}
|
||||
|
||||
let _addLabelToImageUrl = `${
|
||||
@ -215,18 +212,17 @@ export class TagDefaultService extends TagService {
|
||||
}/${repoName}/tags/${tagName}/labels`;
|
||||
return this.http
|
||||
.post(_addLabelToImageUrl, { id: labelId }, HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public deleteLabelToImages(
|
||||
repoName: string,
|
||||
tagName: string,
|
||||
labelId: number
|
||||
): Observable<any> | Promise<any> | any {
|
||||
): Observable<any> {
|
||||
if (!labelId || !tagName || !repoName) {
|
||||
return Promise.reject("Invalid parameters.");
|
||||
return observableThrowError("Invalid parameters.");
|
||||
}
|
||||
|
||||
let _addLabelToImageUrl = `${
|
||||
@ -234,23 +230,21 @@ export class TagDefaultService extends TagService {
|
||||
}/${repoName}/tags/${tagName}/labels/${labelId}`;
|
||||
return this.http
|
||||
.delete(_addLabelToImageUrl)
|
||||
.toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getManifest(
|
||||
repositoryName: string,
|
||||
tag: string
|
||||
): Observable<Manifest> | Promise<Manifest> | Manifest {
|
||||
): Observable<Manifest> {
|
||||
if (!repositoryName || !tag) {
|
||||
return Promise.reject("Bad argument");
|
||||
return observableThrowError("Bad argument");
|
||||
}
|
||||
let url: string = `${this._baseUrl}/${repositoryName}/tags/${tag}/manifest`;
|
||||
return this.http
|
||||
.get(url, HTTP_GET_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response.json() as Manifest)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response.json() as Manifest)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ describe("TagDetailComponent (inline template)", () => {
|
||||
|
||||
tagService = fixture.debugElement.injector.get(TagService);
|
||||
spy = spyOn(tagService, "getTag").and.returnValues(
|
||||
Promise.resolve(mockTag)
|
||||
of(mockTag)
|
||||
);
|
||||
|
||||
let mockData: VulnerabilityItem[] = [];
|
||||
@ -156,9 +156,9 @@ describe("TagDetailComponent (inline template)", () => {
|
||||
vulSpy = spyOn(
|
||||
scanningService,
|
||||
"getVulnerabilityScanningResults"
|
||||
).and.returnValue(Promise.resolve(mockData));
|
||||
).and.returnValue(of(mockData));
|
||||
manifestSpy = spyOn(tagService, "getManifest").and.returnValues(
|
||||
Promise.resolve(mockManifest)
|
||||
of(mockManifest)
|
||||
);
|
||||
userPermissionService = fixture.debugElement.injector.get(UserPermissionService);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Component, Input, Output, EventEmitter, OnInit } from "@angular/core";
|
||||
|
||||
import { TagService, Tag, VulnerabilitySeverity } from "../service/index";
|
||||
import { toPromise } from "../utils";
|
||||
import { ErrorHandler } from "../error-handler/index";
|
||||
import { Label } from "../service/interface";
|
||||
import { forkJoin } from "rxjs";
|
||||
@ -63,8 +62,8 @@ export class TagDetailComponent implements OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.repositoryId && this.tagId) {
|
||||
toPromise<Tag>(this.tagService.getTag(this.repositoryId, this.tagId))
|
||||
.then(response => {
|
||||
this.tagService.getTag(this.repositoryId, this.tagId)
|
||||
.subscribe(response => {
|
||||
this.tagDetails = response;
|
||||
if (
|
||||
this.tagDetails &&
|
||||
@ -91,8 +90,7 @@ export class TagDetailComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
}, error => this.errorHandler.error(error));
|
||||
}
|
||||
this.getTagPermissions(this.projectId);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { Component, Input, Output, EventEmitter, OnInit } from "@angular/core";
|
||||
import { TagService, Manifest } from "../service/index";
|
||||
import { toPromise } from "../utils";
|
||||
import { ErrorHandler } from "../error-handler/index";
|
||||
|
||||
@Component({
|
||||
@ -36,10 +35,8 @@ export class TagHistoryComponent implements OnInit {
|
||||
|
||||
retrieve(repositoryId: string, tagId: string) {
|
||||
this.loading = true;
|
||||
toPromise<Manifest>(
|
||||
this.tagService.getManifest(this.repositoryId, this.tagId)
|
||||
)
|
||||
.then(data => {
|
||||
.subscribe(data => {
|
||||
this.config = JSON.parse(data.config);
|
||||
this.config.history.forEach((ele: any) => {
|
||||
if (ele.created_by !== undefined) {
|
||||
@ -53,8 +50,7 @@ export class TagHistoryComponent implements OnInit {
|
||||
this.history.push(ele);
|
||||
});
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
this.loading = false;
|
||||
});
|
||||
|
@ -24,6 +24,7 @@ import { UserPermissionService, UserPermissionDefaultService } from "../service/
|
||||
import { USERSTATICPERMISSION } from "../service/permission-static";
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
import { Observable, of } from "rxjs";
|
||||
import { delay } from "rxjs/operators";
|
||||
|
||||
describe("TagComponent (inline template)", () => {
|
||||
|
||||
@ -151,7 +152,7 @@ describe("TagComponent (inline template)", () => {
|
||||
|
||||
|
||||
tagService = fixture.debugElement.injector.get(TagService);
|
||||
spy = spyOn(tagService, "getTags").and.returnValues(Promise.resolve(mockTags));
|
||||
spy = spyOn(tagService, "getTags").and.returnValues(of(mockTags).pipe(delay(0)));
|
||||
userPermissionService = fixture.debugElement.injector.get(UserPermissionService);
|
||||
|
||||
spyOn(userPermissionService, "getPermission")
|
||||
@ -166,8 +167,8 @@ describe("TagComponent (inline template)", () => {
|
||||
|
||||
labelService = fixture.debugElement.injector.get(LabelService);
|
||||
|
||||
spyLabels = spyOn(labelService, "getGLabels").and.returnValues(Promise.resolve(mockLabels));
|
||||
spyLabels1 = spyOn(labelService, "getPLabels").withArgs(comp.projectId).and.returnValues(Promise.resolve(mockLabels1));
|
||||
spyLabels = spyOn(labelService, "getGLabels").and.returnValues(of(mockLabels).pipe(delay(0)));
|
||||
spyLabels1 = spyOn(labelService, "getPLabels").withArgs(comp.projectId).and.returnValues(of(mockLabels1).pipe(delay(0)));
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
@ -42,7 +42,6 @@ import { ConfirmationAcknowledgement } from "../confirmation-dialog/confirmation
|
||||
import { Label, Tag, TagClickEvent, RetagRequest } from "../service/interface";
|
||||
|
||||
import {
|
||||
toPromise,
|
||||
CustomComparator,
|
||||
calculatePage,
|
||||
doFiltering,
|
||||
@ -59,7 +58,8 @@ import { USERSTATICPERMISSION } from "../service/permission-static";
|
||||
import { operateChanges, OperateInfo, OperationState } from "../operation/operate";
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
import { ImageNameInputComponent } from "../image-name-input/image-name-input.component";
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
export interface LabelState {
|
||||
iconsShow: boolean;
|
||||
label: Label;
|
||||
@ -263,18 +263,17 @@ export class TagComponent implements OnInit, AfterViewInit {
|
||||
|
||||
this.loading = true;
|
||||
|
||||
toPromise<Tag[]>(this.tagService.getTags(
|
||||
this.tagService.getTags(
|
||||
this.repoName,
|
||||
params))
|
||||
.then((tags: Tag[]) => {
|
||||
params)
|
||||
.subscribe((tags: Tag[]) => {
|
||||
this.signedCon = {};
|
||||
// Do filtering and sorting
|
||||
this.tags = doFiltering<Tag>(tags, state);
|
||||
this.tags = doSorting<Tag>(this.tags, state);
|
||||
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.loading = false;
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
@ -339,7 +338,7 @@ export class TagComponent implements OnInit, AfterViewInit {
|
||||
this.inprogress = true;
|
||||
let labelId = labelInfo.label.id;
|
||||
this.selectedRow = this.selectedTag;
|
||||
toPromise<any>(this.tagService.addLabelToImages(this.repoName, this.selectedRow[0].name, labelId)).then(res => {
|
||||
this.tagService.addLabelToImages(this.repoName, this.selectedRow[0].name, labelId).subscribe(res => {
|
||||
this.refresh();
|
||||
|
||||
// set the selected label in front
|
||||
@ -358,7 +357,7 @@ export class TagComponent implements OnInit, AfterViewInit {
|
||||
|
||||
labelInfo.iconsShow = true;
|
||||
this.inprogress = false;
|
||||
}).catch(err => {
|
||||
}, err => {
|
||||
this.inprogress = false;
|
||||
this.errorHandler.error(err);
|
||||
});
|
||||
@ -370,14 +369,14 @@ export class TagComponent implements OnInit, AfterViewInit {
|
||||
this.inprogress = true;
|
||||
let labelId = labelInfo.label.id;
|
||||
this.selectedRow = this.selectedTag;
|
||||
toPromise<any>(this.tagService.deleteLabelToImages(this.repoName, this.selectedRow[0].name, labelId)).then(res => {
|
||||
this.tagService.deleteLabelToImages(this.repoName, this.selectedRow[0].name, labelId).subscribe(res => {
|
||||
this.refresh();
|
||||
|
||||
// insert the unselected label to groups with the same icons
|
||||
this.sortOperation(this.imageStickLabels, labelInfo);
|
||||
labelInfo.iconsShow = false;
|
||||
this.inprogress = false;
|
||||
}).catch(err => {
|
||||
}, err => {
|
||||
this.inprogress = false;
|
||||
this.errorHandler.error(err);
|
||||
});
|
||||
@ -520,9 +519,9 @@ export class TagComponent implements OnInit, AfterViewInit {
|
||||
let signatures: string[] = [];
|
||||
this.loading = true;
|
||||
|
||||
toPromise<Tag[]>(this.tagService
|
||||
.getTags(this.repoName))
|
||||
.then(items => {
|
||||
this.tagService
|
||||
.getTags(this.repoName)
|
||||
.subscribe(items => {
|
||||
// To keep easy use for vulnerability bar
|
||||
items.forEach((t: Tag) => {
|
||||
if (!t.scan_overview) {
|
||||
@ -548,8 +547,7 @@ export class TagComponent implements OnInit, AfterViewInit {
|
||||
if (this.tags && this.tags.length === 0) {
|
||||
this.refreshRepo.emit(true);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
this.loading = false;
|
||||
});
|
||||
@ -629,12 +627,12 @@ export class TagComponent implements OnInit, AfterViewInit {
|
||||
&& message.state === ConfirmationState.CONFIRMED) {
|
||||
let tags: Tag[] = message.data;
|
||||
if (tags && tags.length) {
|
||||
let promiseLists: any[] = [];
|
||||
let observableLists: any[] = [];
|
||||
tags.forEach(tag => {
|
||||
promiseLists.push(this.delOperate(tag));
|
||||
observableLists.push(this.delOperate(tag));
|
||||
});
|
||||
|
||||
Promise.all(promiseLists).then((item) => {
|
||||
forkJoin(...observableLists).subscribe((item) => {
|
||||
this.selectedRow = [];
|
||||
this.retrieve();
|
||||
});
|
||||
@ -642,7 +640,7 @@ export class TagComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
}
|
||||
|
||||
delOperate(tag: Tag) {
|
||||
delOperate(tag: Tag): Observable<any> | null {
|
||||
// init operation info
|
||||
let operMessage = new OperateInfo();
|
||||
operMessage.name = 'OPERATION.DELETE_TAG';
|
||||
@ -661,26 +659,25 @@ export class TagComponent implements OnInit, AfterViewInit {
|
||||
operateChanges(operMessage, OperationState.failure, wrongInfo);
|
||||
});
|
||||
} else {
|
||||
return toPromise<number>(this.tagService
|
||||
.deleteTag(this.repoName, tag.name))
|
||||
.then(
|
||||
return this.tagService
|
||||
.deleteTag(this.repoName, tag.name)
|
||||
.pipe(map(
|
||||
response => {
|
||||
this.translateService.get("BATCH.DELETED_SUCCESS")
|
||||
.subscribe(res => {
|
||||
operateChanges(operMessage, OperationState.success);
|
||||
});
|
||||
}).catch(error => {
|
||||
}), catchError(error => {
|
||||
if (error.status === 503) {
|
||||
forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPOSITORY.TAGS_NO_DELETE')).subscribe(res => {
|
||||
return forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
|
||||
this.translateService.get('REPOSITORY.TAGS_NO_DELETE')).pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res[1]);
|
||||
});
|
||||
return;
|
||||
}));
|
||||
}
|
||||
this.translateService.get("BATCH.DELETED_FAILURE").subscribe(res => {
|
||||
return this.translateService.get("BATCH.DELETED_FAILURE").pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res);
|
||||
});
|
||||
});
|
||||
}));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ import {
|
||||
Tag
|
||||
} from '../service/index';
|
||||
import { ErrorHandler } from '../error-handler/index';
|
||||
import { toPromise } from '../utils';
|
||||
import { ChannelService } from '../channel/index';
|
||||
import { JobLogService } from "../service/index";
|
||||
|
||||
@ -111,8 +110,8 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.onSubmitting = true;
|
||||
|
||||
toPromise<any>(this.scanningService.startVulnerabilityScanning(this.repoName, this.tagId))
|
||||
.then(() => {
|
||||
this.scanningService.startVulnerabilityScanning(this.repoName, this.tagId)
|
||||
.subscribe(() => {
|
||||
this.onSubmitting = false;
|
||||
|
||||
// Forcely change status to queued after successful submitting
|
||||
@ -133,8 +132,7 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
||||
this.getSummary();
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onSubmitting = false;
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
@ -145,8 +143,8 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
||||
return;
|
||||
}
|
||||
|
||||
toPromise<Tag>(this.tagService.getTag(this.repoName, this.tagId))
|
||||
.then((t: Tag) => {
|
||||
this.tagService.getTag(this.repoName, this.tagId)
|
||||
.subscribe((t: Tag) => {
|
||||
// To keep the same summary reference, use value copy.
|
||||
this.copyValue(t.scan_overview);
|
||||
|
||||
@ -160,8 +158,7 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
||||
this.stateCheckTimer = null;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
this.retryCounter++;
|
||||
if (this.retryCounter >= RETRY_TIMES) {
|
||||
|
@ -64,7 +64,7 @@ describe('ResultGridComponent (inline template)', () => {
|
||||
}
|
||||
|
||||
spy = spyOn(scanningService, 'getVulnerabilityScanningResults')
|
||||
.and.returnValue(Promise.resolve(mockData));
|
||||
.and.returnValue(of(mockData));
|
||||
|
||||
|
||||
userPermissionService = fixture.debugElement.injector.get(UserPermissionService);
|
||||
|
@ -7,7 +7,6 @@ import {
|
||||
import { ErrorHandler } from '../error-handler/index';
|
||||
import { forkJoin } from "rxjs";
|
||||
|
||||
import { toPromise } from '../utils';
|
||||
import { ChannelService } from "../channel/channel.service";
|
||||
import { UserPermissionService } from "../service/permission.service";
|
||||
import { USERSTATICPERMISSION } from "../service/permission-static";
|
||||
@ -37,12 +36,11 @@ export class ResultGridComponent implements OnInit {
|
||||
}
|
||||
|
||||
loadResults(repositoryId: string, tagId: string): void {
|
||||
toPromise<VulnerabilityItem[]>(this.scanningService.getVulnerabilityScanningResults(repositoryId, tagId))
|
||||
.then((results: VulnerabilityItem[]) => {
|
||||
this.scanningService.getVulnerabilityScanningResults(repositoryId, tagId)
|
||||
.subscribe((results: VulnerabilityItem[]) => {
|
||||
this.dataCache = results;
|
||||
this.scanningResults = this.dataCache.filter((item: VulnerabilityItem) => item.id !== '');
|
||||
})
|
||||
.catch(error => { this.errorHandler.error(error); });
|
||||
}, error => { this.errorHandler.error(error); });
|
||||
}
|
||||
|
||||
// TODO: Should query from back-end service
|
||||
|
45
src/portal/package-lock.json
generated
45
src/portal/package-lock.json
generated
@ -134,15 +134,13 @@
|
||||
"version": "1.37.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz",
|
||||
"integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.21",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz",
|
||||
"integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"mime-db": "~1.37.0"
|
||||
}
|
||||
@ -6286,8 +6284,7 @@
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
|
||||
"optional": true
|
||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
@ -6308,14 +6305,12 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
||||
"optional": true
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@ -6330,20 +6325,17 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
|
||||
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
|
||||
"optional": true
|
||||
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"optional": true
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
|
||||
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
|
||||
"optional": true
|
||||
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@ -6460,8 +6452,7 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
|
||||
"optional": true
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@ -6473,7 +6464,6 @@
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
|
||||
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@ -6488,7 +6478,6 @@
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@ -6496,14 +6485,12 @@
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||
"optional": true
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz",
|
||||
"integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"yallist": "^3.0.0"
|
||||
@ -6522,7 +6509,6 @@
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@ -6603,8 +6589,7 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
|
||||
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
|
||||
"optional": true
|
||||
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@ -6616,7 +6601,6 @@
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@ -6702,8 +6686,7 @@
|
||||
"safe-buffer": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
|
||||
"optional": true
|
||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
@ -6739,7 +6722,6 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
||||
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
@ -6759,7 +6741,6 @@
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
@ -6803,14 +6784,12 @@
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
||||
"optional": true
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz",
|
||||
"integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=",
|
||||
"optional": true
|
||||
"integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -114,7 +114,7 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
|
||||
this.checkOnGoing = true;
|
||||
this.session
|
||||
.checkUserExisting("email", this.account.email)
|
||||
.then((res: boolean) => {
|
||||
.subscribe((res: boolean) => {
|
||||
this.checkOnGoing = false;
|
||||
this.validationStateMap[key] = !res;
|
||||
if (res) {
|
||||
@ -123,8 +123,7 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
|
||||
this.mailAlreadyChecked[this.account.email] = {
|
||||
result: res
|
||||
}; // Tag it checked
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.checkOnGoing = false;
|
||||
this.validationStateMap[key] = false; // Not valid @ backend
|
||||
});
|
||||
@ -185,18 +184,16 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
|
||||
if (this.canRename) {
|
||||
this.session
|
||||
.updateAccountSettings(this.account)
|
||||
.then(() => {
|
||||
.subscribe(() => {
|
||||
this.session.renameAdmin(this.account)
|
||||
.then(() => {
|
||||
.subscribe(() => {
|
||||
this.msgHandler.showSuccess("PROFILE.RENAME_SUCCESS");
|
||||
this.opened = false;
|
||||
this.logOut();
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.msgHandler.handleError(error);
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.isOnCalling = false;
|
||||
this.error = error;
|
||||
if (this.msgHandler.isAppLevel(error)) {
|
||||
@ -288,12 +285,11 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
|
||||
} else {
|
||||
this.session
|
||||
.updateAccountSettings(this.account)
|
||||
.then(() => {
|
||||
.subscribe(() => {
|
||||
this.isOnCalling = false;
|
||||
this.opened = false;
|
||||
this.msgHandler.showSuccess("PROFILE.SAVE_SUCCESS");
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.isOnCalling = false;
|
||||
this.error = error;
|
||||
if (this.msgHandler.isAppLevel(error)) {
|
||||
|
@ -79,14 +79,13 @@ export class ForgotPasswordComponent {
|
||||
|
||||
this.onGoing = true;
|
||||
this.pwdService.sendResetPasswordMail(this.email)
|
||||
.then(response => {
|
||||
.subscribe(response => {
|
||||
this.onGoing = false;
|
||||
this.isSuccess = true;
|
||||
this.inlineAlert.showInlineSuccess({
|
||||
message: "RESET_PWD.SUCCESS"
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
this.inlineAlert.showInlineError(error);
|
||||
});
|
||||
|
@ -166,12 +166,11 @@ export class PasswordSettingComponent implements AfterViewChecked {
|
||||
new_password: this.pwdForm.value.newPassword,
|
||||
old_password: this.pwdForm.value.oldPassword
|
||||
})
|
||||
.then(() => {
|
||||
.subscribe(() => {
|
||||
this.onCalling = false;
|
||||
this.opened = false;
|
||||
this.msgHandler.showSuccess("CHANGE_PWD.SAVE_SUCCESS");
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onCalling = false;
|
||||
this.error = error;
|
||||
if (this.msgHandler.isAppLevel(error)) {
|
||||
|
@ -13,6 +13,8 @@
|
||||
// limitations under the License.
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http, URLSearchParams } from '@angular/http';
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
|
||||
|
||||
import { PasswordSetting } from './password-setting';
|
||||
@ -27,36 +29,31 @@ export class PasswordSettingService {
|
||||
|
||||
constructor(private http: Http) { }
|
||||
|
||||
changePassword(userId: number, setting: PasswordSetting): Promise<any> {
|
||||
changePassword(userId: number, setting: PasswordSetting): Observable<any> {
|
||||
if (!setting || setting.new_password.trim() === "" || setting.old_password.trim() === "") {
|
||||
return Promise.reject("Invalid data");
|
||||
return observableThrowError("Invalid data");
|
||||
}
|
||||
|
||||
let putUrl = passwordChangeEndpoint.replace(":user_id", userId + "");
|
||||
return this.http.put(putUrl, JSON.stringify(setting), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(() => null)
|
||||
.catch(error => {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
.pipe(map(() => null)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
sendResetPasswordMail(email: string): Promise<any> {
|
||||
sendResetPasswordMail(email: string): Observable<any> {
|
||||
if (!email) {
|
||||
return Promise.reject("Invalid email");
|
||||
return observableThrowError("Invalid email");
|
||||
}
|
||||
|
||||
let getUrl = sendEmailEndpoint + "?email=" + email;
|
||||
return this.http.get(getUrl, HTTP_GET_OPTIONS).toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
return this.http.get(getUrl, HTTP_GET_OPTIONS)
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
resetPassword(uuid: string, newPassword: string): Promise<any> {
|
||||
resetPassword(uuid: string, newPassword: string): Observable<any> {
|
||||
if (!uuid || !newPassword) {
|
||||
return Promise.reject("Invalid reset uuid or password");
|
||||
return observableThrowError("Invalid reset uuid or password");
|
||||
}
|
||||
|
||||
let body: URLSearchParams = new URLSearchParams();
|
||||
@ -64,11 +61,8 @@ export class PasswordSettingService {
|
||||
body.set("password", newPassword);
|
||||
|
||||
return this.http.post(resetPasswordEndpoint, body.toString(), HTTP_FORM_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -105,12 +105,11 @@ export class ResetPasswordComponent implements OnInit {
|
||||
|
||||
this.onGoing = true;
|
||||
this.pwdService.resetPassword(this.resetUuid, this.password)
|
||||
.then(() => {
|
||||
.subscribe(() => {
|
||||
this.onGoing = false;
|
||||
this.resetOk = true;
|
||||
this.inlineAlert.showInlineSuccess({ message: 'RESET_PWD.RESET_OK' });
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
if (this.msgHandler.isAppLevel(error)) {
|
||||
this.close();
|
||||
|
@ -89,8 +89,8 @@ export class SignInComponent implements AfterViewChecked, OnInit {
|
||||
|
||||
// Make sure the updated configuration can be loaded
|
||||
this.appConfigService.load()
|
||||
.then(updatedConfig => this.appConfig = updatedConfig)
|
||||
.catch(error => {
|
||||
.subscribe(updatedConfig => this.appConfig = updatedConfig
|
||||
, error => {
|
||||
// Catch the error
|
||||
console.error("Failed to load bootstrap options with error: ", error);
|
||||
});
|
||||
@ -241,7 +241,7 @@ export class SignInComponent implements AfterViewChecked, OnInit {
|
||||
|
||||
// Call the service to send out the http request
|
||||
this.session.signIn(this.signInCredential)
|
||||
.then(() => {
|
||||
.subscribe(() => {
|
||||
// Set status
|
||||
// Keep it ongoing to keep the button 'disabled'
|
||||
// this.signInStatus = signInStatusNormal;
|
||||
@ -256,8 +256,7 @@ export class SignInComponent implements AfterViewChecked, OnInit {
|
||||
} else {
|
||||
this.router.navigateByUrl(this.redirectUrl);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.handleError(error);
|
||||
});
|
||||
}
|
||||
|
@ -13,11 +13,12 @@
|
||||
// limitations under the License.
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http, URLSearchParams } from '@angular/http';
|
||||
import 'rxjs/add/operator/toPromise';
|
||||
// import 'rxjs/add/operator/toPromise';
|
||||
|
||||
import { SignInCredential } from '../../shared/sign-in-credential';
|
||||
import {HTTP_FORM_OPTIONS} from "../../shared/shared.utils";
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
const signInUrl = '/c/login';
|
||||
/**
|
||||
*
|
||||
@ -32,12 +33,12 @@ export class SignInService {
|
||||
constructor(private http: Http) {}
|
||||
|
||||
// Handle the related exceptions
|
||||
handleError(error: any): Promise<any> {
|
||||
return Promise.reject(error.message || error);
|
||||
handleError(error: any): Observable<any> {
|
||||
return observableThrowError(error.message || error);
|
||||
}
|
||||
|
||||
// Submit signin form to backend (NOT restful service)
|
||||
signIn(signInCredential: SignInCredential): Promise<any> {
|
||||
signIn(signInCredential: SignInCredential): Observable<any> {
|
||||
// Build the form package
|
||||
const body = new URLSearchParams();
|
||||
body.set('principal', signInCredential.principal);
|
||||
@ -45,8 +46,8 @@ export class SignInService {
|
||||
|
||||
// Trigger Http
|
||||
return this.http.post(signInUrl, body.toString(), HTTP_FORM_OPTIONS)
|
||||
.toPromise()
|
||||
.then(() => null)
|
||||
.catch(this.handleError);
|
||||
.pipe(map(() => null)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -92,13 +92,12 @@ export class SignUpPageComponent implements OnInit {
|
||||
this.onGoing = true;
|
||||
|
||||
this.userService.addUser(u)
|
||||
.then(() => {
|
||||
.subscribe(() => {
|
||||
this.onGoing = false;
|
||||
this.msgService.announceMessage(200, "", AlertType.SUCCESS);
|
||||
// Navigate to embeded sign-in
|
||||
this.router.navigate(['harbor', 'sign-in']);
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
this.error = error;
|
||||
this.msgService.announceMessage(error.status || 500, "", AlertType.WARNING);
|
||||
|
@ -119,13 +119,12 @@ export class SignUpComponent {
|
||||
this.onGoing = true;
|
||||
|
||||
this.userService.addUser(u)
|
||||
.then(() => {
|
||||
.subscribe(() => {
|
||||
this.onGoing = false;
|
||||
this.opened = false;
|
||||
this.modal.close();
|
||||
this.userCreation.emit(u);
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
this.error = error;
|
||||
this.inlienAlert.showInlineError(error);
|
||||
|
@ -19,7 +19,8 @@ import { CookieService } from 'ngx-cookie';
|
||||
import { AppConfig } from './app-config';
|
||||
import { CookieKeyOfAdmiral, HarborQueryParamKey } from './shared/shared.const';
|
||||
import { maintainUrlQueryParmas, HTTP_GET_OPTIONS} from './shared/shared.utils';
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
export const systemInfoEndpoint = "/api/systeminfo";
|
||||
/**
|
||||
* Declare service to handle the bootstrap options
|
||||
@ -38,9 +39,9 @@ export class AppConfigService {
|
||||
private http: Http,
|
||||
private cookie: CookieService) { }
|
||||
|
||||
public load(): Promise<AppConfig> {
|
||||
return this.http.get(systemInfoEndpoint, HTTP_GET_OPTIONS).toPromise()
|
||||
.then(response => {
|
||||
public load(): Observable<AppConfig> {
|
||||
return this.http.get(systemInfoEndpoint, HTTP_GET_OPTIONS)
|
||||
.pipe(map(response => {
|
||||
this.configurations = response.json() as AppConfig;
|
||||
|
||||
// Read admiral endpoint from cookie if existing
|
||||
@ -51,7 +52,7 @@ export class AppConfigService {
|
||||
}
|
||||
|
||||
return this.configurations;
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public getConfig(): AppConfig {
|
||||
|
@ -13,7 +13,8 @@
|
||||
// limitations under the License.
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
|
||||
import { SearchResults } from './search-results';
|
||||
import { HTTP_GET_OPTIONS } from "../../shared/shared.utils";
|
||||
@ -35,15 +36,15 @@ export class GlobalSearchService {
|
||||
* Search related artifacts with the provided keyword
|
||||
*
|
||||
* ** deprecated param {string} keyword
|
||||
* returns {Promise<SearchResults>}
|
||||
* returns {Observable<SearchResults>}
|
||||
*
|
||||
* @memberOf GlobalSearchService
|
||||
*/
|
||||
doSearch(term: string): Promise<SearchResults> {
|
||||
doSearch(term: string): Observable<SearchResults> {
|
||||
let searchUrl = searchEndpoint + "?q=" + term;
|
||||
|
||||
return this.http.get(searchUrl, HTTP_GET_OPTIONS).toPromise()
|
||||
.then(response => response.json() as SearchResults)
|
||||
.catch(error => Promise.reject(error));
|
||||
return this.http.get(searchUrl, HTTP_GET_OPTIONS)
|
||||
.pipe(map(response => response.json() as SearchResults)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -140,12 +140,11 @@ export class SearchResultComponent implements OnInit, OnDestroy {
|
||||
this.onGoing = true;
|
||||
|
||||
this.search.doSearch(term)
|
||||
.then(searchResults => {
|
||||
.subscribe(searchResults => {
|
||||
this.onGoing = false;
|
||||
this.originalCopy = searchResults; // Keep the original data
|
||||
this.searchResults = this.clone(searchResults);
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
this.msgHandler.handleError(error);
|
||||
});
|
||||
|
@ -198,6 +198,17 @@
|
||||
</clr-tooltip>
|
||||
</div>
|
||||
<!-- End of ldap group admin dn -->
|
||||
<div class="form-group">
|
||||
<label>{{'CONFIG.LDAP.LDAP_GROUP_MEMBERSHIP' | translate}}</label>
|
||||
<input name="ldapGroupMembership" class="padding-right-28" type="text" #ldapGroupFilterInput="ngModel"
|
||||
[(ngModel)]="currentConfig.ldap_group_membership_attribute.value" id="ldapGroupMembership" size="40" [disabled]="disabled(currentConfig.ldap_group_membership_attribute)">
|
||||
<clr-tooltip>
|
||||
<clr-icon clrTooltipTrigger shape="info-circle" size="24"></clr-icon>
|
||||
<clr-tooltip-content clrPosition="top-right" clrSize="lg" *clrIfOpen>
|
||||
<span>{{'CONFIG.LDAP.LDAP_GROUP_MEMBERSHIP_INFO' | translate}}</span>
|
||||
</clr-tooltip-content>
|
||||
</clr-tooltip>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="ldapGroupScope">{{'CONFIG.LDAP.GROUP_SCOPE' | translate}}</label>
|
||||
<div class="select">
|
||||
@ -216,6 +227,7 @@
|
||||
</clr-tooltip-content>
|
||||
</clr-tooltip>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
<section class="form-block">
|
||||
<div class="form-group" *ngIf="showSelfReg">
|
||||
|
@ -20,6 +20,7 @@ import { MessageHandlerService } from '../../shared/message-handler/message-hand
|
||||
import { ConfirmMessageHandler } from '../config.msg.utils';
|
||||
import { AppConfigService } from '../../app-config.service';
|
||||
import { ConfigurationService } from '../config.service';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
const fakePass = 'aWpLOSYkIzJTTU4wMDkx';
|
||||
|
||||
@Component({
|
||||
@ -114,11 +115,10 @@ export class ConfigurationAuthComponent implements OnChanges {
|
||||
|
||||
this.testingLDAPOnGoing = true;
|
||||
this.configService.testLDAPServer(ldapSettings)
|
||||
.then(respone => {
|
||||
.subscribe(respone => {
|
||||
this.testingLDAPOnGoing = false;
|
||||
this.msgHandler.showSuccess('CONFIG.TEST_LDAP_SUCCESS');
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.testingLDAPOnGoing = false;
|
||||
let err = error._body;
|
||||
if (!err || !err.trim()) {
|
||||
@ -187,14 +187,14 @@ export class ConfigurationAuthComponent implements OnChanges {
|
||||
if (!isEmpty(changes)) {
|
||||
this.onGoing = true;
|
||||
this.configService.saveConfiguration(changes)
|
||||
.then(response => {
|
||||
.subscribe(response => {
|
||||
this.onGoing = false;
|
||||
this.retrieveConfig();
|
||||
// Reload bootstrap option
|
||||
this.appConfigService.load().catch(error => console.error('Failed to reload bootstrap option with error: ', error));
|
||||
this.appConfigService.load().subscribe(() => {}
|
||||
, error => console.error('Failed to reload bootstrap option with error: ', error));
|
||||
this.msgHandler.showSuccess('CONFIG.SAVE_SUCCESS');
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
this.msgHandler.handleError(error);
|
||||
});
|
||||
@ -207,7 +207,7 @@ export class ConfigurationAuthComponent implements OnChanges {
|
||||
retrieveConfig(): void {
|
||||
this.onGoing = true;
|
||||
this.configService.getConfiguration()
|
||||
.then((configurations: Configuration) => {
|
||||
.subscribe((configurations: Configuration) => {
|
||||
this.onGoing = false;
|
||||
|
||||
// Add two password fields
|
||||
@ -216,8 +216,7 @@ export class ConfigurationAuthComponent implements OnChanges {
|
||||
this.currentConfig = configurations;
|
||||
// Keep the original copy of the data
|
||||
this.originalConfig = clone(configurations);
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
this.msgHandler.handleError(error);
|
||||
});
|
||||
|
@ -129,7 +129,8 @@ export class ConfigurationComponent implements OnInit, OnDestroy {
|
||||
|
||||
handleAppConfig(event) {
|
||||
// Reload bootstrap option
|
||||
this.appConfigService.load().catch(error => console.error('Failed to reload bootstrap option with error: ', error));
|
||||
this.appConfigService.load().subscribe(() => {}
|
||||
, error => console.error('Failed to reload bootstrap option with error: ', error));
|
||||
}
|
||||
|
||||
public tabLinkClick(tabLink: string) {
|
||||
@ -139,7 +140,7 @@ export class ConfigurationComponent implements OnInit, OnDestroy {
|
||||
retrieveConfig(): void {
|
||||
this.onGoing = true;
|
||||
this.configService.getConfiguration()
|
||||
.then((configurations: Configuration) => {
|
||||
.subscribe((configurations: Configuration) => {
|
||||
this.onGoing = false;
|
||||
|
||||
// Add two password fields
|
||||
@ -149,8 +150,7 @@ export class ConfigurationComponent implements OnInit, OnDestroy {
|
||||
this.allConfig = configurations;
|
||||
// Keep the original copy of the data
|
||||
this.originalCopy = clone(configurations);
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
this.msgHandler.handleError(error);
|
||||
});
|
||||
|
@ -13,7 +13,8 @@
|
||||
// limitations under the License.
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
|
||||
import { Configuration } from '@harbor/ui';
|
||||
|
||||
@ -28,30 +29,27 @@ export class ConfigurationService {
|
||||
|
||||
constructor(private http: Http) { }
|
||||
|
||||
public getConfiguration(): Promise<Configuration> {
|
||||
return this.http.get(configEndpoint, HTTP_GET_OPTIONS).toPromise()
|
||||
.then(response => response.json() as Configuration)
|
||||
.catch(error => Promise.reject(error));
|
||||
public getConfiguration(): Observable<Configuration> {
|
||||
return this.http.get(configEndpoint, HTTP_GET_OPTIONS)
|
||||
.pipe(map(response => response.json() as Configuration)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public saveConfiguration(values: any): Promise<any> {
|
||||
public saveConfiguration(values: any): Observable<any> {
|
||||
return this.http.put(configEndpoint, JSON.stringify(values), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public testMailServer(mailSettings: any): Promise<any> {
|
||||
public testMailServer(mailSettings: any): Observable<any> {
|
||||
return this.http.post(emailEndpoint, JSON.stringify(mailSettings), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public testLDAPServer(ldapSettings: any): Promise<any> {
|
||||
public testLDAPServer(ldapSettings: any): Observable<any> {
|
||||
return this.http.post(ldapEndpoint, JSON.stringify(ldapSettings), HTTP_JSON_OPTIONS)
|
||||
.toPromise()
|
||||
.then(response => response)
|
||||
.catch(error => Promise.reject(error));
|
||||
.pipe(map(response => response)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -100,11 +100,10 @@ export class ConfigurationEmailComponent implements OnChanges {
|
||||
|
||||
this.testingMailOnGoing = true;
|
||||
this.configService.testMailServer(mailSettings)
|
||||
.then(response => {
|
||||
.subscribe(response => {
|
||||
this.testingMailOnGoing = false;
|
||||
this.msgHandler.showSuccess('CONFIG.TEST_MAIL_SUCCESS');
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.testingMailOnGoing = false;
|
||||
let err = error._body;
|
||||
if (!err) {
|
||||
@ -134,12 +133,11 @@ export class ConfigurationEmailComponent implements OnChanges {
|
||||
if (!isEmpty(changes)) {
|
||||
this.onGoing = true;
|
||||
this.configService.saveConfiguration(changes)
|
||||
.then(response => {
|
||||
.subscribe(response => {
|
||||
this.onGoing = false;
|
||||
this.retrieveConfig();
|
||||
this.msgHandler.showSuccess('CONFIG.SAVE_SUCCESS');
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
this.msgHandler.handleError(error);
|
||||
});
|
||||
@ -152,7 +150,7 @@ export class ConfigurationEmailComponent implements OnChanges {
|
||||
retrieveConfig(): void {
|
||||
this.onGoing = true;
|
||||
this.configService.getConfiguration()
|
||||
.then((configurations: Configuration) => {
|
||||
.subscribe((configurations: Configuration) => {
|
||||
this.onGoing = false;
|
||||
|
||||
// Add two password fields
|
||||
@ -160,8 +158,7 @@ export class ConfigurationEmailComponent implements OnChanges {
|
||||
this.currentConfig = configurations;
|
||||
// Keep the original copy of the data
|
||||
this.originalConfig = clone(configurations);
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.onGoing = false;
|
||||
this.msgHandler.handleError(error);
|
||||
});
|
||||
|
@ -81,14 +81,13 @@ export class CreateProjectComponent implements OnInit, OnDestroy {
|
||||
if (this.isNameValid) {
|
||||
// Check exiting from backend
|
||||
this.projectService
|
||||
.checkProjectExists(cont.value).toPromise()
|
||||
.then(() => {
|
||||
.checkProjectExists(cont.value)
|
||||
.subscribe(() => {
|
||||
// Project existing
|
||||
this.isNameValid = false;
|
||||
this.nameTooltipText = "PROJECT.NAME_ALREADY_EXISTS";
|
||||
this.checkOnGoing = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.checkOnGoing = false;
|
||||
});
|
||||
} else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
import {forkJoin as observableForkJoin, Subscription } from "rxjs";
|
||||
import {forkJoin as observableForkJoin, Subscription, forkJoin } from "rxjs";
|
||||
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -39,7 +39,8 @@ import {operateChanges, OperateInfo, OperationService, OperationState} from "@ha
|
||||
|
||||
import { Project } from "../project";
|
||||
import { ProjectService } from "../project.service";
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { throwError as observableThrowError } from "rxjs";
|
||||
@Component({
|
||||
selector: "list-project",
|
||||
templateUrl: "list-project.component.html",
|
||||
@ -165,8 +166,8 @@ export class ListProjectComponent implements OnDestroy {
|
||||
if (this.filteredType > 0) {
|
||||
passInFilteredType = this.filteredType - 1;
|
||||
}
|
||||
this.proService.listProjects(this.searchKeyword, passInFilteredType, pageNumber, this.pageSize).toPromise()
|
||||
.then(response => {
|
||||
this.proService.listProjects(this.searchKeyword, passInFilteredType, pageNumber, this.pageSize)
|
||||
.subscribe(response => {
|
||||
// Get total count
|
||||
if (response.headers) {
|
||||
let xHeader: string = response.headers.get("X-Total-Count");
|
||||
@ -181,8 +182,7 @@ export class ListProjectComponent implements OnDestroy {
|
||||
this.projects = doSorting<Project>(this.projects, state);
|
||||
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.loading = false;
|
||||
this.msgHandler.handleError(error);
|
||||
});
|
||||
@ -244,7 +244,7 @@ export class ListProjectComponent implements OnDestroy {
|
||||
projects.forEach(data => {
|
||||
observableLists.push(this.delOperate(data));
|
||||
});
|
||||
Promise.all(observableLists).then(item => {
|
||||
forkJoin(...observableLists).subscribe(item => {
|
||||
let st: State = this.getStateAfterDeletion();
|
||||
this.selectedRow = [];
|
||||
if (!st) {
|
||||
@ -267,24 +267,24 @@ export class ListProjectComponent implements OnDestroy {
|
||||
this.operationService.publishInfo(operMessage);
|
||||
|
||||
return this.proService.deleteProject(project.project_id)
|
||||
.then(
|
||||
.pipe(map(
|
||||
() => {
|
||||
this.translate.get("BATCH.DELETED_SUCCESS").subscribe(res => {
|
||||
operateChanges(operMessage, OperationState.success);
|
||||
});
|
||||
},
|
||||
}), catchError(
|
||||
error => {
|
||||
if (error && error.status === 412) {
|
||||
observableForkJoin(this.translate.get("BATCH.DELETED_FAILURE"),
|
||||
this.translate.get("PROJECT.FAILED_TO_DELETE_PROJECT")).subscribe(res => {
|
||||
return observableForkJoin(this.translate.get("BATCH.DELETED_FAILURE"),
|
||||
this.translate.get("PROJECT.FAILED_TO_DELETE_PROJECT")).pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res[1]);
|
||||
});
|
||||
}));
|
||||
} else {
|
||||
this.translate.get("BATCH.DELETED_FAILURE").subscribe(res => {
|
||||
return this.translate.get("BATCH.DELETED_FAILURE").pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res);
|
||||
});
|
||||
}));
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
|
@ -24,3 +24,8 @@
|
||||
background-image: linear-gradient(180deg,#f5f5f5 0,#e8e8e8);
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.modal-body{
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ import {
|
||||
import { Response } from '@angular/http';
|
||||
import { NgForm } from '@angular/forms';
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import { Subject } from "rxjs";
|
||||
import { Subject, forkJoin } from "rxjs";
|
||||
|
||||
|
||||
|
||||
@ -94,11 +94,6 @@ export class AddMemberComponent implements AfterViewChecked, OnInit, OnDestroy {
|
||||
hasProjectAdminRole = (<Project>resolverData['projectResolver']).has_project_admin_role;
|
||||
}
|
||||
if (hasProjectAdminRole) {
|
||||
this.userService.getUsersNameList()
|
||||
.then(users => {
|
||||
this.userLists = users;
|
||||
});
|
||||
|
||||
this.nameChecker.pipe(
|
||||
debounceTime(500),
|
||||
distinctUntilChanged(), )
|
||||
@ -108,33 +103,31 @@ export class AddMemberComponent implements AfterViewChecked, OnInit, OnDestroy {
|
||||
this.isMemberNameValid = cont.valid;
|
||||
if (cont.valid) {
|
||||
this.checkOnGoing = true;
|
||||
this.memberService
|
||||
.listMembers(this.projectId, cont.value).toPromise()
|
||||
.then((members: Member[]) => {
|
||||
if (members.filter(m => { return m.entity_name === cont.value; }).length > 0) {
|
||||
this.isMemberNameValid = false;
|
||||
this.memberTooltip = 'MEMBER.USERNAME_ALREADY_EXISTS';
|
||||
}
|
||||
this.checkOnGoing = false;
|
||||
})
|
||||
.catch(error => {
|
||||
this.checkOnGoing = false;
|
||||
});
|
||||
// username autocomplete
|
||||
if (this.userLists && this.userLists.length) {
|
||||
this.selectUserName = [];
|
||||
this.userLists.forEach(data => {
|
||||
if (data.username.startsWith(cont.value) && !this.memberList.find(mem => mem.entity_name === data.username)) {
|
||||
if (this.selectUserName.length < 10) {
|
||||
this.selectUserName.push(data.username);
|
||||
forkJoin(this.userService.getUsersNameList(cont.value, 20), this.memberService
|
||||
.listMembers(this.projectId, cont.value)).subscribe((res: Array<any>) => {
|
||||
this.userLists = res[0];
|
||||
if (res[1].filter(m => { return m.entity_name === cont.value; }).length > 0) {
|
||||
this.isMemberNameValid = false;
|
||||
this.memberTooltip = 'MEMBER.USERNAME_ALREADY_EXISTS';
|
||||
}
|
||||
this.checkOnGoing = false;
|
||||
if (this.userLists && this.userLists.length) {
|
||||
this.selectUserName = [];
|
||||
this.userLists.forEach(data => {
|
||||
if (data.username.startsWith(cont.value) && !this.memberList.find(mem => mem.entity_name === data.username)) {
|
||||
if (this.selectUserName.length < 10) {
|
||||
this.selectUserName.push(data.username);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
let changeTimer = setInterval(() => this.ref.detectChanges(), 200);
|
||||
setTimeout(() => {
|
||||
clearInterval(changeTimer);
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
let changeTimer = setInterval(() => this.ref.detectChanges(), 200);
|
||||
setTimeout(() => {
|
||||
clearInterval(changeTimer);
|
||||
}, 2000);
|
||||
}
|
||||
}, error => {
|
||||
this.checkOnGoing = false;
|
||||
});
|
||||
} else {
|
||||
this.memberTooltip = 'MEMBER.USERNAME_IS_REQUIRED';
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import { finalize } from 'rxjs/operators';
|
||||
// limitations under the License.
|
||||
import { Component, OnInit, ViewChild, OnDestroy, ChangeDetectionStrategy, ChangeDetectorRef } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { Subscription, forkJoin } from "rxjs";
|
||||
import { Subscription, forkJoin, Observable } from "rxjs";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { operateChanges, OperateInfo, OperationService, OperationState } from "@harbor/ui";
|
||||
|
||||
@ -33,7 +33,8 @@ import { MemberService } from "./member.service";
|
||||
import { AddMemberComponent } from "./add-member/add-member.component";
|
||||
import { AppConfigService } from "../../app-config.service";
|
||||
import { UserPermissionService, USERSTATICPERMISSION, ErrorHandler } from "@harbor/ui";
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { throwError as observableThrowError } from "rxjs";
|
||||
@Component({
|
||||
templateUrl: "member.component.html",
|
||||
styleUrls: ["./member.component.scss"],
|
||||
@ -185,22 +186,25 @@ export class MemberComponent implements OnInit, OnDestroy {
|
||||
let changeOperate = (projectId: number, member: Member, ) => {
|
||||
return this.memberService
|
||||
.changeMemberRole(projectId, member.id, roleId)
|
||||
.then(() => this.batchChangeRoleInfos[member.id] = 'done')
|
||||
.catch(error => this.messageHandlerService.handleError(error + ": " + member.entity_name));
|
||||
.pipe(map(() => this.batchChangeRoleInfos[member.id] = 'done')
|
||||
, catchError(error => {
|
||||
this.messageHandlerService.handleError(error + ": " + member.entity_name);
|
||||
return observableThrowError(error);
|
||||
}));
|
||||
};
|
||||
|
||||
// Preparation for members role change
|
||||
this.batchChangeRoleInfos = {};
|
||||
let RoleChangePromises: Promise<any>[] = [];
|
||||
let RoleChangeObservables: Observable<any>[] = [];
|
||||
members.forEach(member => {
|
||||
if (member.entity_type === 'u' && member.entity_id === this.currentUser.user_id) {
|
||||
return;
|
||||
}
|
||||
this.batchChangeRoleInfos[member.id] = 'pending';
|
||||
RoleChangePromises.push(changeOperate(this.projectId, member));
|
||||
RoleChangeObservables.push(changeOperate(this.projectId, member));
|
||||
});
|
||||
|
||||
Promise.all(RoleChangePromises).then(() => {
|
||||
forkJoin(...RoleChangeObservables).subscribe(() => {
|
||||
this.retrieve(this.projectId, "");
|
||||
});
|
||||
}
|
||||
@ -231,7 +235,7 @@ export class MemberComponent implements OnInit, OnDestroy {
|
||||
|
||||
deleteMembers(members: Member[]) {
|
||||
if (!members) { return; }
|
||||
let memberDeletingPromises: Promise<any>[] = [];
|
||||
let memberDeletingObservables: Observable<any>[] = [];
|
||||
|
||||
// Function to delete specific member
|
||||
let deleteMember = (projectId: number, member: Member) => {
|
||||
@ -251,22 +255,21 @@ export class MemberComponent implements OnInit, OnDestroy {
|
||||
|
||||
return this.memberService
|
||||
.deleteMember(projectId, member.id)
|
||||
.then(response => {
|
||||
.pipe(map(response => {
|
||||
this.translate.get("BATCH.DELETED_SUCCESS").subscribe(res => {
|
||||
operateChanges(operMessage, OperationState.success);
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
this.translate.get("BATCH.DELETED_FAILURE").subscribe(res => {
|
||||
}), catchError(error => {
|
||||
return this.translate.get("BATCH.DELETED_FAILURE").pipe(map(res => {
|
||||
operateChanges(operMessage, OperationState.failure, res);
|
||||
});
|
||||
});
|
||||
}));
|
||||
}));
|
||||
};
|
||||
|
||||
// Deleting member then wating for results
|
||||
members.forEach(member => memberDeletingPromises.push(deleteMember(this.projectId, member)));
|
||||
members.forEach(member => memberDeletingObservables.push(deleteMember(this.projectId, member)));
|
||||
|
||||
Promise.all(memberDeletingPromises).then(() => {
|
||||
forkJoin(...memberDeletingObservables).subscribe(() => {
|
||||
this.selectedRow = [];
|
||||
this.batchOps = 'idle';
|
||||
this.retrieve(this.projectId, "");
|
||||
|
@ -67,17 +67,17 @@ export class MemberService {
|
||||
catchError(error => observableThrowError(error)), );
|
||||
}
|
||||
|
||||
changeMemberRole(projectId: number, userId: number, roleId: number): Promise<any> {
|
||||
changeMemberRole(projectId: number, userId: number, roleId: number): Observable<any> {
|
||||
return this.http
|
||||
.put(`/api/projects/${projectId}/members/${userId}`, { role_id: roleId }, HTTP_JSON_OPTIONS).toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.put(`/api/projects/${projectId}/members/${userId}`, { role_id: roleId }, HTTP_JSON_OPTIONS)
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
deleteMember(projectId: number, memberId: number): Promise<any> {
|
||||
deleteMember(projectId: number, memberId: number): Observable<any> {
|
||||
return this.http
|
||||
.delete(`/api/projects/${projectId}/members/${memberId}`).toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.delete(`/api/projects/${projectId}/members/${memberId}`)
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ import { Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@a
|
||||
import { Project } from './project';
|
||||
import { ProjectService } from './project.service';
|
||||
import { SessionService } from '../shared/session.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
|
||||
|
||||
import { Roles } from '../shared/shared.const';
|
||||
@ -30,7 +32,7 @@ export class ProjectRoutingResolver implements Resolve<Project> {
|
||||
private projectService: ProjectService,
|
||||
private router: Router) { }
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<Project> {
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Project> {
|
||||
// Support both parameters and query parameters
|
||||
let projectId = route.params['id'];
|
||||
if (!projectId) {
|
||||
@ -38,8 +40,7 @@ export class ProjectRoutingResolver implements Resolve<Project> {
|
||||
}
|
||||
return this.projectService
|
||||
.getProject(projectId)
|
||||
.toPromise()
|
||||
.then((project: Project) => {
|
||||
.pipe(map((project: Project) => {
|
||||
if (project) {
|
||||
let currentUser = this.sessionService.getCurrentUser();
|
||||
if (currentUser) {
|
||||
@ -58,10 +59,10 @@ export class ProjectRoutingResolver implements Resolve<Project> {
|
||||
this.router.navigate(['/harbor', 'projects']);
|
||||
return null;
|
||||
}
|
||||
}).catch(error => {
|
||||
}, catchError (error => {
|
||||
this.router.navigate(['/harbor', 'projects']);
|
||||
return null;
|
||||
});
|
||||
})));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -71,11 +71,11 @@ export class ProjectService {
|
||||
catchError(error => observableThrowError(error)), );
|
||||
}
|
||||
|
||||
deleteProject(projectId: number): Promise<any> {
|
||||
deleteProject(projectId: number): Observable<any> {
|
||||
return this.http
|
||||
.delete(`/api/projects/${projectId}`).toPromise()
|
||||
.then(response => response.status)
|
||||
.catch(error => Promise.reject(error));
|
||||
.delete(`/api/projects/${projectId}`)
|
||||
.pipe(map(response => response.status)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
checkProjectExists(projectName: string): Observable<any> {
|
||||
|
@ -51,7 +51,7 @@
|
||||
<clr-icon shape="check-circle" *ngSwitchCase="false" size="20" class="color-green"></clr-icon>
|
||||
<clr-icon shape="times-circle" *ngSwitchCase="true" size="16" class="color-red red-position"></clr-icon>
|
||||
</clr-dg-cell>
|
||||
<clr-dg-cell>{{r.expiresat * 1000 | date: 'short'}}</clr-dg-cell>
|
||||
<clr-dg-cell>{{r.expires_at * 1000 | date: 'short'}}</clr-dg-cell>
|
||||
<clr-dg-cell>{{r.description}}</clr-dg-cell>
|
||||
</clr-dg-row>
|
||||
<clr-dg-footer>
|
||||
|
@ -3,7 +3,7 @@ export class Robot {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
expiresat: number;
|
||||
expires_at: number;
|
||||
disabled: boolean;
|
||||
access: {
|
||||
isPull: boolean;
|
||||
|
@ -42,8 +42,8 @@ export class ReplicationPageComponent implements OnInit, AfterViewInit {
|
||||
ngOnInit(): void {
|
||||
this.projectIdentify = +this.route.snapshot.parent.params['id'];
|
||||
this.getReplicationPermissions(this.projectIdentify);
|
||||
this.proService.listProjects("", undefined).toPromise()
|
||||
.then(response => {
|
||||
this.proService.listProjects("", undefined)
|
||||
.subscribe(response => {
|
||||
let projects = response.json() as Project[];
|
||||
if (projects.length) {
|
||||
let project = projects.find(data => data.project_id === this.projectIdentify);
|
||||
|
@ -46,8 +46,8 @@ export class TopRepoComponent implements OnInit {
|
||||
// Get top popular repositories
|
||||
getTopRepos() {
|
||||
this.topRepoService.getTopRepos()
|
||||
.then(repos => this.topRepos = repos )
|
||||
.catch(error => {
|
||||
.subscribe(repos => this.topRepos = repos
|
||||
, error => {
|
||||
this.messageHandlerService.handleError(error);
|
||||
});
|
||||
}
|
||||
|
@ -13,7 +13,8 @@
|
||||
// limitations under the License.
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
import { Repository } from '@harbor/ui';
|
||||
|
||||
import {HTTP_GET_OPTIONS} from "../../shared/shared.utils";
|
||||
@ -35,13 +36,13 @@ export class TopRepoService {
|
||||
* Get top popular repositories
|
||||
*
|
||||
* ** deprecated param {string} keyword
|
||||
* returns {Promise<TopRepo>}
|
||||
* returns {Observable<TopRepo>}
|
||||
*
|
||||
* @memberOf GlobalSearchService
|
||||
*/
|
||||
getTopRepos(): Promise<Repository[]> {
|
||||
return this.http.get(topRepoEndpoint, HTTP_GET_OPTIONS).toPromise()
|
||||
.then(response => response.json() as Repository[])
|
||||
.catch(error => Promise.reject(error));
|
||||
getTopRepos(): Observable<Repository[]> {
|
||||
return this.http.get(topRepoEndpoint, HTTP_GET_OPTIONS)
|
||||
.pipe(map(response => response.json() as Repository[])
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ export class NewUserFormComponent implements AfterViewChecked, OnInit {
|
||||
|
||||
this.checkOnGoing[key] = true;
|
||||
this.session.checkUserExisting("username", this.newUser.username)
|
||||
.then((res: boolean) => {
|
||||
.subscribe((res: boolean) => {
|
||||
this.checkOnGoing[key] = false;
|
||||
this.validationStateMap[key] = !res;
|
||||
if (res) {
|
||||
@ -129,8 +129,7 @@ export class NewUserFormComponent implements AfterViewChecked, OnInit {
|
||||
result: res
|
||||
}; // Tag it checked
|
||||
this.forceRefreshView(2000);
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.checkOnGoing[key] = false;
|
||||
this.validationStateMap[key] = false; // Not valid @ backend
|
||||
this.forceRefreshView(2000);
|
||||
@ -152,7 +151,7 @@ export class NewUserFormComponent implements AfterViewChecked, OnInit {
|
||||
// Mail changed
|
||||
this.checkOnGoing[key] = true;
|
||||
this.session.checkUserExisting("email", this.newUser.email)
|
||||
.then((res: boolean) => {
|
||||
.subscribe((res: boolean) => {
|
||||
this.checkOnGoing[key] = false;
|
||||
this.validationStateMap[key] = !res;
|
||||
if (res) {
|
||||
@ -162,8 +161,7 @@ export class NewUserFormComponent implements AfterViewChecked, OnInit {
|
||||
result: res
|
||||
}; // Tag it checked
|
||||
this.forceRefreshView(2000);
|
||||
})
|
||||
.catch(error => {
|
||||
}, error => {
|
||||
this.checkOnGoing[key] = false;
|
||||
this.validationStateMap[key] = false; // Not valid @ backend
|
||||
this.forceRefreshView(2000);
|
||||
|
@ -25,7 +25,8 @@ import { AppConfigService } from '../../app-config.service';
|
||||
import { maintainUrlQueryParmas } from '../../shared/shared.utils';
|
||||
import { MessageHandlerService } from '../message-handler/message-handler.service';
|
||||
import { SearchTriggerService } from '../../base/global-search/search-trigger.service';
|
||||
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError, observable } from "rxjs";
|
||||
@Injectable()
|
||||
export class AuthCheckGuard implements CanActivate, CanActivateChild {
|
||||
constructor(
|
||||
@ -45,7 +46,7 @@ export class AuthCheckGuard implements CanActivate, CanActivateChild {
|
||||
return false;
|
||||
}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> | boolean {
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
// When routing change, clear
|
||||
this.msgHandler.clear();
|
||||
if (this.appConfigService.getConfig().read_only.toString() === 'true') {
|
||||
@ -53,8 +54,7 @@ export class AuthCheckGuard implements CanActivate, CanActivateChild {
|
||||
}
|
||||
|
||||
this.searchTrigger.closeSearch(true);
|
||||
return new Promise((resolve, reject) => {
|
||||
// Before activating, we firstly need to confirm whether the route is coming from peer part - admiral
|
||||
return new Observable( observer => {
|
||||
let queryParams = route.queryParams;
|
||||
if (queryParams) {
|
||||
if (queryParams[AdmiralQueryParamKey]) {
|
||||
@ -66,20 +66,19 @@ export class AuthCheckGuard implements CanActivate, CanActivateChild {
|
||||
}
|
||||
|
||||
this.router.navigateByUrl(keyRemovedUrl);
|
||||
return resolve(false);
|
||||
return observer.next(false);
|
||||
}
|
||||
}
|
||||
|
||||
let user = this.authService.getCurrentUser();
|
||||
if (!user) {
|
||||
this.authService.retrieveUser()
|
||||
.then(() => resolve(true))
|
||||
.catch(error => {
|
||||
.subscribe(() => observer.next(true)
|
||||
, error => {
|
||||
// If is guest, skip it
|
||||
if (this.isGuest(route, state)) {
|
||||
return resolve(true);
|
||||
return observer.next(true);
|
||||
}
|
||||
// Session retrieving failed then redirect to sign-in
|
||||
// Session retrieving failed.pipe(map redirect to sign-in
|
||||
// no matter what status code is.
|
||||
// Please pay attention that route 'HARBOR_ROOT' and 'EMBEDDED_SIGN_IN' support anonymous user
|
||||
if (state.url !== CommonRoutes.HARBOR_ROOT && !state.url.startsWith(CommonRoutes.EMBEDDED_SIGN_IN)) {
|
||||
@ -87,18 +86,18 @@ export class AuthCheckGuard implements CanActivate, CanActivateChild {
|
||||
queryParams: { "redirect_url": state.url }
|
||||
};
|
||||
this.router.navigate([CommonRoutes.EMBEDDED_SIGN_IN], navigatorExtra);
|
||||
return resolve(false);
|
||||
return observer.next(false);
|
||||
} else {
|
||||
return resolve(true);
|
||||
return observer.next(true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return resolve(true);
|
||||
return observer.next(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> | boolean {
|
||||
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
return this.canActivate(route, state);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import { ConfirmationDialogService } from '../confirmation-dialog/confirmation-d
|
||||
import { ConfirmationMessage } from '../confirmation-dialog/confirmation-message';
|
||||
import { ConfirmationState, ConfirmationTargets } from '../shared.const';
|
||||
import { TagRepositoryComponent } from '../../repository/tag-repository/tag-repository.component';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class LeavingRepositoryRouteDeactivate implements CanDeactivate<TagRepositoryComponent> {
|
||||
@ -33,9 +34,9 @@ export class LeavingRepositoryRouteDeactivate implements CanDeactivate<TagReposi
|
||||
canDeactivate(
|
||||
tagRepo: TagRepositoryComponent,
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot): Promise<boolean> | boolean {
|
||||
state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
// Confirmation before leaving config route
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Observable((observer) => {
|
||||
if (tagRepo && tagRepo.hasChanges()) {
|
||||
let msg: ConfirmationMessage = new ConfirmationMessage(
|
||||
"CONFIG.LEAVING_CONFIRMATION_TITLE",
|
||||
@ -48,16 +49,16 @@ export class LeavingRepositoryRouteDeactivate implements CanDeactivate<TagReposi
|
||||
return this.confirmation.confirmationConfirm$.subscribe(confirmMsg => {
|
||||
if (confirmMsg && confirmMsg.source === ConfirmationTargets.REPOSITORY) {
|
||||
if (confirmMsg.state === ConfirmationState.CONFIRMED) {
|
||||
return resolve(true);
|
||||
return observer.next(true);
|
||||
} else {
|
||||
return resolve(false); // Prevent leading route
|
||||
return observer.next(false); // Prevent leading route
|
||||
}
|
||||
} else {
|
||||
return resolve(true); // Should go on
|
||||
return observer.next(true); // Should go on
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return resolve(true);
|
||||
return observer.next(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import {
|
||||
import { SessionService } from '../../shared/session.service';
|
||||
import { ProjectService } from '../../project/project.service';
|
||||
import { CommonRoutes } from '../../shared/shared.const';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class MemberGuard implements CanActivate, CanActivateChild {
|
||||
@ -29,49 +30,51 @@ export class MemberGuard implements CanActivate, CanActivateChild {
|
||||
private projectService: ProjectService,
|
||||
private router: Router) {}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> | boolean {
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
let projectId = route.params['id'];
|
||||
this.sessionService.setProjectMembers([]);
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Observable((observer) => {
|
||||
let user = this.sessionService.getCurrentUser();
|
||||
if (user === null) {
|
||||
this.sessionService.retrieveUser()
|
||||
.then(() => resolve(this.checkMemberStatus(state.url, projectId)))
|
||||
.catch(() => {
|
||||
.subscribe(() => {
|
||||
this.checkMemberStatus(state.url, projectId).subscribe((res) => observer.next(res));
|
||||
}
|
||||
, error => {
|
||||
this.router.navigate([CommonRoutes.HARBOR_DEFAULT]);
|
||||
resolve(false);
|
||||
observer.next(false);
|
||||
});
|
||||
} else {
|
||||
return resolve(this.checkMemberStatus(state.url, projectId));
|
||||
this.checkMemberStatus(state.url, projectId).subscribe((res) => observer.next(res));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
checkMemberStatus(url: string, projectId: number): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
checkMemberStatus(url: string, projectId: number): Observable<boolean> {
|
||||
return new Observable<boolean>((observer) => {
|
||||
this.projectService.checkProjectMember(projectId)
|
||||
.subscribe(res => {
|
||||
this.sessionService.setProjectMembers(res);
|
||||
return resolve(true);
|
||||
return observer.next(true);
|
||||
},
|
||||
() => {
|
||||
// Add exception for repository in project detail router activation.
|
||||
this.projectService.getProject(projectId).subscribe(project => {
|
||||
if (project.metadata && project.metadata.public === 'true') {
|
||||
return resolve(true);
|
||||
return observer.next(true);
|
||||
}
|
||||
this.router.navigate([CommonRoutes.HARBOR_DEFAULT]);
|
||||
return resolve(false);
|
||||
return observer.next(false);
|
||||
},
|
||||
() => {
|
||||
this.router.navigate([CommonRoutes.HARBOR_DEFAULT]);
|
||||
return resolve(false);
|
||||
return observer.next(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> | boolean {
|
||||
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
return this.canActivate(route, state);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import {
|
||||
} from '@angular/router';
|
||||
import { CommonRoutes } from '../../shared/shared.const';
|
||||
import { AppConfigService } from '../../app-config.service';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class ModeGuard implements CanActivate, CanActivateChild {
|
||||
@ -27,28 +28,28 @@ export class ModeGuard implements CanActivate, CanActivateChild {
|
||||
private router: Router,
|
||||
private appConfigService: AppConfigService) { }
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> | boolean {
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
// Show the right sign-in page for different modes
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Observable((observer) => {
|
||||
if (this.appConfigService.isIntegrationMode()) {
|
||||
if (state.url.startsWith(CommonRoutes.SIGN_IN)) {
|
||||
this.router.navigate([CommonRoutes.EMBEDDED_SIGN_IN], route.queryParams);
|
||||
resolve(false);
|
||||
observer.next(false);
|
||||
} else {
|
||||
resolve(true);
|
||||
observer.next(true);
|
||||
}
|
||||
} else {
|
||||
if (state.url.startsWith(CommonRoutes.EMBEDDED_SIGN_IN)) {
|
||||
this.router.navigate([CommonRoutes.SIGN_IN], route.queryParams);
|
||||
resolve(false);
|
||||
observer.next(false);
|
||||
} else {
|
||||
resolve(true);
|
||||
observer.next(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> | boolean {
|
||||
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
return this.canActivate(route, state);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user