grim/port-authority
Clone
Summary
Browse
Changes
Graph
remove our local style sheet
feature/semantic-ui
2015-02-07, Gary Kramlich
c342717de4c7
remove our local style sheet
var
manifest
=
angular
.
module
(
"manifest"
,
[
'ui.bootstrap'
])
.
config
([
'$compileProvider'
,
function
(
$compileProvider
)
{
$compileProvider
.
aHrefSanitizationWhitelist
(
/^\s*(https?|ftp|mailto|chrome-extension):/
);
$compileProvider
.
imgSrcSanitizationWhitelist
(
/^\s*(https?|ftp|mailto|chrome-extension):/
);
}
]);
manifest
.
factory
(
"manifestREST"
,
function
(
$http
)
{
return
{
search
:
function
(
registry
,
query
)
{
var
url
=
registry
+
"/v1/search"
;
if
(
query
)
{
url
+=
"?q="
+
query
;
}
return
$http
.
get
(
url
);
},
images
:
function
(
registry
,
repo
)
{
return
$http
.
get
(
registry
+
"/v1/repositories/"
+
repo
+
"/images"
)
.
success
(
function
(
images
)
{
for
(
var
i
=
0
;
i
<
images
.
length
;
i
++
)
{
var
image
=
images
[
i
];
image
[
'short_id'
]
=
image
.
id
.
substring
(
0
,
8
);
}
return
images
;
});
},
tags
:
function
(
registry
,
repo
)
{
return
$http
.
get
(
registry
+
"/v1/repositories/"
+
repo
+
"/tags"
);
},
info
:
function
(
registry
,
image
)
{
return
$http
.
get
(
registry
+
"/v1/images/"
+
image
+
"/json"
);
}
}
});
function
ManifestController
(
$scope
,
manifestREST
)
{
$scope
.
debug
=
false
;
$scope
.
refreshing
=
false
;
$scope
.
refreshing_repo
=
false
;
$scope
.
registry
=
"registry.hub.docker.com"
;
$scope
.
query
=
"node"
;
$scope
.
repos
=
null
;
$scope
.
repo
=
null
;
$scope
.
error
=
null
;
$scope
.
tags
=
null
;
$scope
.
clipboard
=
null
;
/* google analytics stuff */
$scope
.
ga_service
=
analytics
.
getService
(
"Port Authority Chrome"
);
$scope
.
ga_tracker
=
$scope
.
ga_service
.
getTracker
(
"UA-47592312-2"
);
$scope
.
ga_tracker
.
sendAppView
(
"main"
);
$scope
.
refresh
=
function
()
{
$scope
.
repos
=
null
;
$scope
.
repo
=
null
;
$scope
.
tags
=
null
;
$scope
.
clipboard
=
null
;
$scope
.
refreshing
=
true
;
if
(
$scope
.
registry
.
indexOf
(
"http://"
)
!==
0
&&
$scope
.
registry
.
indexOf
(
"https://"
)
!==
0
)
{
$scope
.
registry
=
"http://"
+
$scope
.
registry
;
}
$scope
.
ga_tracker
.
sendEvent
(
"refresh"
,
"search param"
,
"used"
,
$scope
.
query
!==
""
);
var
timer_start
=
window
.
performance
.
now
();
manifestREST
.
search
(
$scope
.
registry
,
$scope
.
query
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
var
timer_end
=
window
.
performance
.
now
();
$scope
.
ga_tracker
.
sendEvent
(
"refresh"
,
"status"
,
"refresh success"
);
$scope
.
ga_tracker
.
sendTiming
(
"refresh"
,
"load time"
,
timer_end
-
timer_start
,
"refresh success timing"
);
$scope
.
repos
=
data
.
results
.
map
(
function
(
repo
)
{
var
library_prefix
=
"library/"
if
(
repo
.
name
.
indexOf
(
library_prefix
)
==
0
)
{
repo
.
name
=
repo
.
name
.
substring
(
library_prefix
.
length
,
repo
.
name
.
length
);
}
repo
.
expanded
=
false
;
$scope
.
refreshing
=
false
;
return
repo
;
});
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
var
timer_end
=
window
.
performance
.
now
();
$scope
.
ga_tracker
.
sendEvent
(
"refresh"
,
"status"
,
"refresh failed"
);
$scope
.
ga_tracker
.
sendTiming
(
"refresh"
,
"load time"
,
timer_end
-
timer_start
,
"refresh failed timing"
);
$scope
.
refreshing
=
false
;
console
.
log
(
"Failed to get the registry list: "
+
status
);
});
};
$scope
.
select_repo
=
function
(
repo
)
{
if
(
repo
===
$scope
.
repo
)
{
return
;
}
$scope
.
ga_tracker
.
sendEvent
(
"repo"
,
"selected"
,
"repo-selected"
);
$scope
.
repo
=
repo
;
$scope
.
tags
=
null
;
$scope
.
refreshing_repo
=
true
;
manifestREST
.
tags
(
$scope
.
registry
,
repo
.
name
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
/* the docker registry returns a list of objects like
* [{"layer", "deadb33f", "name": "latest"}]
* and the private registry returns a dictionary of tag
* names to images. Like:
* {"latest", "deadb33f"}
* This function will normalize them into a sorted list like
* [
* ["foo", "latest"]
* ["latest"],
* ]
* Image IDs are thrown away because we don't care about them.
*/
$scope
.
ga_tracker
.
sendEvent
(
"repo"
,
"get tags"
,
"success"
);
$scope
.
tags
=
[];
if
(
data
.
constructor
===
Array
)
{
/* registry.hub.docker.com */
var
dtags
=
{};
for
(
var
ntag
in
data
)
{
var
tag
=
data
[
ntag
];
dtags
[
tag
.
layer
]
=
dtags
[
tag
.
layer
]
||
[];
dtags
[
tag
.
layer
].
push
(
tag
.
name
);
}
var
tags
=
[];
for
(
var
tag
in
dtags
)
{
tags
.
push
(
dtags
[
tag
].
sort
());
}
$scope
.
tags
=
tags
.
sort
(
function
(
a
,
b
)
{
return
a
[
0
]
-
b
[
0
]});
}
else
if
(
data
!==
null
&&
typeof
data
===
'object'
)
{
/* private registries */
var
dtags
=
{};
for
(
var
tag
in
data
)
{
var
layer
=
data
[
tag
];
dtags
[
layer
]
=
dtags
[
layer
]
||
[];
dtags
[
layer
].
push
(
tag
);
}
var
tags
=
[];
for
(
var
tag
in
dtags
)
{
tags
.
push
(
dtags
[
tag
].
sort
());
}
$scope
.
tags
=
tags
.
sort
(
function
(
a
,
b
)
{
return
a
[
0
]
-
b
[
0
]});
}
$scope
.
refreshing_repo
=
false
;
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
$scope
.
ga_tracker
.
sendEvent
(
"repo"
,
"get tags"
,
"failed"
);
console
.
log
(
"Failed to get the tag list: "
+
status
);
$scope
.
refreshing_repo
=
false
;
});
};
$scope
.
copy_tag
=
function
(
tag
)
{
$scope
.
ga_tracker
.
sendEvent
(
"copy"
,
"clicked"
);
$scope
.
clipboard
=
$scope
.
registry
+
"/"
+
$scope
.
repo
.
name
+
":"
+
tag
;
};
}